Polymorphism, Abstract Class, Abstract Method and Final Keyword in Java

Polymorphism,
  •  Abstract Class,  
  • Abstract Method 
  •  Final Keyword

Abstract Class 

  • Abstract class is declared with abstract key word.
  • The class contains abstract methods.
  • Abstract methods are declared inside abstract class.
  • Abstract methods by thare declared with abstract key word.
  • Abstract methods are defined e child class  
  • Abstract class cannot have any object.
  • The child class of the abstract class must override all the abstract methods of the parent class.
  • If the child class does not override any abstract method of the parent class it should also be declared abstract.
  • Reference variable can be declared of abstract class.
  • Abstract class may have abstract and concrete methods.
  • Non abstract methods are also called concrete methods.
  • All the members of the abstract class can be accessed only through the object of the child class.
Example #1 Abstract Class 

Abstract Class 
  • It allows a super class to specify methods that will be common to all its derived classes and does not provide any definition of these methods.
  • It allows subclasses to define the specific implementation of some or all of those methods.
  • Its another way java implements one interface, multiple methods aspect of polymorphism.
  • By combining inheritance with overridden methods ,a super class can define the general form of the methods that will be used by all of its subclasses.
  • This is also called run time polymorphism.

Polymorphism 

  • The object referred by the reference variable of the super class is determined at run time.
  • The binding of object to the overridden method is performed at run time.
  • The reference variable of the parent class is binded  dynamically to different methods at run time.Therefore its called dynamic/late binding.

Final Keyword

lThe class declared with final key word cannot be inherited.
The method declared with final keyword cannot be overridden
.


Post a Comment

0 Comments