benefits of using abstract class in java and interface code example
Example 1: is it necessary for abstract class to have abstract method
No, abstract class can have zero abstract methods.
Example 2: abstract class example in java
//abstract parent class
abstract class Animal{
//abstract method
public abstract void sound();
}
//Dog class extends Animal class
public class Dog extends Animal{
public void sound(){
System.out.println("Woof");
}
public static void main(String args[]){
Animal obj = new Dog();
obj.sound();
}
}