Topic:   The abstract class?
Apr 26, 2021 09:50 1 Replies 60 Views VAMSI

What is the abstract class?

Prev Next
Topic Replies (1)
  1. 1
    idnkx user

    ROHAN

    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.
    1. abstract class Bike{
    2. abstract void run();
    3. }
    4. class Honda4 extends Bike{
    5. void run(){System.out.println("running safely");}
    6. public static void main(String args[]){
    7. Bike obj = new Honda4();
    8. obj.run();
    9. }
    10. }
    11. Output
    12. running safely

Leave a Reply
Guest User

Not sure what course is right for you?

Choose the right course for you.
Get the help of our experts and find a course that best suits your needs.


Let`s Connect