Answers for "When a class extend an abstract class it must declare and provide body for each method in the said abstract class."

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();
   }
}
Posted by: Guest on November-11-2020
0

Is it mandatory for an abstract class to have abstract methods?

No, abstract class can have zero abstract methods.
Posted by: Guest on November-28-2020

Code answers related to "When a class extend an abstract class it must declare and provide body for each method in the said abstract class."

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language