Core Java interview questions on Inheritance


1.What is inheritance?
Child class acquires the properties of parent class.

2.Does java support multiple inheritance?
No

3.Why multiple inheritance not supported in java?
Because ambiguous  

4.What is the base class of all classes?
Java.lang.object

5.What is an object class?
Object is a instance of class.

6.Is constructor inherited?

In simple words, a constructor cannot be inherited,
since in subclasses it has a different name (the name of the subclass).

class A {
   A();
}

class B extends A{
   B();
}


You can do only:

B b = new B();  // and not new A()



7.What is super.(dot)keyword in java?
It is a reference variable that is used to refer immediate parent class object.



Related Post

Comments


©candidjava.com