Tuesday, January 10, 2017

JAVA Inheritance Exercise

Do this JAVA Inheritance Exercises Try your best !  Avoid Running the code at first.
guess what and check your answers in the run time.    


                                                                                       


================================================

class A{
int a=10;
static int b=20;
static{
System.out.print("1 ");
}
{
System.out.print("2 ");
}
A(){
System.out.print("3 ");
}
static void mA(){
System.out.print("4 ");
}
}

class B extends A{
int x=10;
static int y=20;
static{
System.out.print("5 ");
}
{
System.out.print("6 ");
}
B(){
System.out.print("7 ");
}
static void mB(){
System.out.print("8 ");
}
}
class Demo{
public static void main(String args[]){
// place code here
}
}
//A. new A()
//B. new A(); new A();
//C. A.mA();
//D. A.mA(); new A();
//E. new B();
//F. new B();new B();
//G. B.mB(); new B();
//H. B.mA();

======================================================================

Comment if you have any doubts ..

0 comments:

Post a Comment