Monday, 29 August 2011

what is inheritance? java interview questions ...

Ans:

  • Java Inheritance defines an is-a relationship between a superclass and its subclasses.
  • The child class can use the methods and variables of the superclass and add to them its own methods and variables .
  • The keyword extends is used by the sub class to inherit the features of super class .
  •   Using inheritance we can achieve the concepts of reusability.

syntax:

             class A{

              //class A codes

            }

             class B{

             //class B codes and also use class A members

             }

No comments: