Answers for "What is abstract class? Explain with 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();
   }
}
Posted by: Guest on November-11-2020
0

can you declare an abstract method in a non abstract class

No. A normal class(non-abstract class) cannot have abstract methods.
Posted by: Guest on November-14-2020

Code answers related to "What is abstract class? Explain with example"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language