Abstract is a keyword in java. So its a reserved word in java. general meaning of abstract is to hide the implementation, only show the outer structure. Now in computer science its meaning is that user can have their own implementation with abstract method.

Where we can use abstract keyword ?
Abstract can be used with class and method.

By using abstract with the method a user can able to have their own implementation according to their wish. Its the facility given by the java vendor to the user to have their own implementation.

Abstract with class

Using abstract modifier before the class name can make a class as abstract. Making a class as abstract means we cannot instantiate that class.

Syntax :

abstract  < access_modifier > class < class_name > {  } 

< access_modifier > --> Only public is used with abstract . Private and protected are not used.

To know more about abstract class Click here !

Abstract with method

Declaring abstract modifier with the method name will make that method as abstract. An abstract method cannot have their implementation where it is declared, it must be override in its sub-classes.

Syntax :

abstract  < access_modifier > < return_type > < method_name > {  } 

< access_modifier > --> Only public and protected are used. Private cannot be used with it.


0 comments:

Post a Comment

Ads 468x60px

.

Ads

.

Featured Posts

Popular Posts

Like Us On FaceBook

Total Pageviews

Online Members

Live Traffic