Inheritance

September 10th, 2006 Admin Posted in Inheritance No Comments »

Inheritance

  • In Interfaces, all the methods will not have body.
  • If the interface is public, all the methods are implicitly treated as public, even though we don’t specify any access-specifier(can’t be private, protected).
  • Interfaces are implemented by using a keyword implements.
  • A single  class can implement any no of interfaces.(multiple inheritance)
  • While implementing methods of an interface ,they must be declared as public.
  • If all the methods of an interface are not implemented then the class must be declared as abstract
  • An Interface can  extend other interfaces.
  • Data Instances declared in interfaces are implicitly static and final and they must be initialized.

One class can gain the features  from the existing class is called inheritance.This can be adapted in Java by using  extends keyword.

Example :

class   A
{    ……   }
class   B  extends  A
{  ….   }

AddThis Social Bookmark Button