Observe the following coding in Java and find the output:--
class A{
A()
{
System.out.print("R");
}
}
class B extends A { B() { System.out.print("A"); } }
public class C extends B{ C() { System.out.print("J"); }
public static void main(String args[])
{
C ob=new C();
}
}
log on to comprogzz.in for more such coding !!
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
In inheritance concept, the superclass constructor is called first then subclass constructor. In this the superclass A's constructor will be called first, then B's and then at last C's constructor.