implement abstract class code example
Example 1: 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();
}
}
Example 2: can abstract class have implementation java
abstract classes have no implementation of functions methods inside it which declared as abstract methods. classes which are inheriting it have to overriden it. and final absract class can not be overriden