This is one of the important and basic features of core Java. You
know the class in which you can declare variables,have constructor and
member functions,you can create object of an class. As you know in
inheritance you can extend one class to another (Inheritance in Java) .
However abstract class has some different features as following :
However abstract class has some different features as following :
- Abstract class can be declared by preceding abstract keyword to class then class name .i.e abstract class Test { } // this is the abstract class.
- We can not instantiate abstract class object.
- Abstract class may inherit another class.
- Abstract class may contain abstract method (ex. abstract void fun()) which has only signature , it does not have method body.
- Abstract class may contain non abstract method having body.
- Abstract class may contain constructor as like normal class.
- Use of abstract class or interface(Interface) depends upon the scenario where to be used.
- As like a class it does not allow multiple inheritance.
No comments:
Post a Comment