Abstract Classes and Interfaces Flashcards

1
Q

What is the abstract class?

A

A class that is declared as abstract is known as an abstract class. It needs to be extended and its method implemented. It cannot be instantiated. It can have abstract methods, non-abstract methods, constructors, and static methods. It can also have the final methods which will force the subclass not to change the body of the method. Consider the following example.

abstract class Bike{  
       abstract void run();  
}  
class Honda4 extends Bike{  
void run(){
       System.out.println("running safely");
}  
public static void main(String args[]){  
           Bike obj = new Honda4();  
           obj.run();  
           }  
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly