Answers for "is it necessary for abstract class to have abstract method"

7

What are abstract methods in java

An abstract method is the method which does’nt have any body. 
Abstract method is declared with
keyword abstract and semicolon in place of method body.

  public abstract void <method name>();
Ex : public abstract void getDetails();
It is the responsibility of subclass to provide implementation to 
abstract method defined in abstract class
Posted by: Guest on November-30-2020
2

is it necessary for abstract class to have abstract method

Abstract classes CAN have non-abstract methods.
Posted by: Guest on August-27-2021
5

is it necessary for abstract class to have abstract method

No, abstract class can have zero abstract methods.
Posted by: Guest on November-28-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
0

write a program in which an abstract class is being defined containg an abstract method omputer(int a, int b) and a non abstract method as well

abstract class Sum{
   
   public abstract int compute(int a, int b);
   public void disp(){
	System.out.println("Method of class Sum");
   }
}
class Demo extends Sum{

   public int compute(int a, int b){
	return a+b;
   }
   public static void main(String args[]){
	Sum obj = new Demo();
	System.out.println(obj.compute(3, 7));
	obj.disp();
   }
}
Posted by: Guest on December-10-2020
0

Can we add a non-abstract method into abstract class?

Yes, we can. An abstract class can have both abstract and non-abstract methods
Posted by: Guest on November-28-2020

Code answers related to "is it necessary for abstract class to have abstract method"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language