Create a class called  Disp containing the instance variable n , to display the following classes message "I am Good" whenever n<0 and the message "I am Great"   otherwise . This  class is inherited by another class Display  containing the instance variable n. This class contains   a method that will instantiate the two instance variable  and a method which display the message "I Love Apple" if n>10 and display "I Love Mangoes" otherwise. Create a class containing  the main() and display the messages according to the value you have given to the two variables. 

source file name: Display.java

class Disp

{

int n;

void display()

{

if(n<0)

System.out.println("I am Good");

else

System.out.println("I am Great");

}

}


class Display extends Disp

{

int m;


public Display(int mm,int nn)      

     {

     m=mm;

     n=nn;

     }

void display()

{

if(m>10)

System.out.println("I Love Apple");

else

System.out.println("I Love mangoes");


if(n<0)

System.out.println("I Am Good");

else

System.out.println("I Am Great");

}


public static void main(String as[])

{

Display d=new Display(10,-5);

d.display();

}

}


output 1:

D:\JavaPrograms\InheritancePrgs>javac Display.java

Display d=new Display(100 , 15);

D:\JavaPrograms\InheritancePrgs>java Display

I Love Apple

I Am Great

output 2:

D:\JavaPrograms\InheritancePrgs>javac Display.java

Display d=new Display(10,-5);

D:\JavaPrograms\InheritancePrgs>java Display

I Love mangoes

I Am Good

D:\JavaPrograms\InheritancePrgs>