You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class which is declared as Abstract is known as an Abstract Class
It can have abstract and non-abstract methods
We cannot create object of an Abstract class
abstractclassBike{ // abstract classabstractvoidrun(); // abstract method
}
classHeroextendsBike{
// Error if run() methods is undefined: Hero is not abstract and does not override abstract method run() in Bikevoidrun(){
System.out.println("Run from Hero");
}
}
classtest{
publicstaticvoidmain(Stringargs[]){
Heroobj = newHero(); // object of class Hero createdobj.run(); // Output : Run from Hero/* Bike obj2 = new Bike(); // object of abstract class cannot be created obj2.run(); // error: Bike is abstract; cannot be instantiated */
}
}