+ 2
Is it mandatory to have only abstract methods in an abstract class?
3 Réponses
+ 4
Yes we can have an abstract classwithout Abstract Methods as both are independent concepts. Declaring aclass abstract means that it can not be instantiated on its own and can onlybe sub classed. Declaring a method abstract means that Method will be defined in the subclass
public abstract class AbstractClass{
public String nonAbstractMethodOne(String param1,String param2){
String param = param1 + param2;
return param; }
public static void nonAbstractMethodTwo(String param){
System.out.println("Value of param is "+param); } }
The abstract class used in java signifies that you can't create an object of the class. And an abstract method the subclasses have to provide an implementation for that method.
So you can easily define an abstract class without any abstract method.
+ 2
Thank you guys for answering my question 😊😊
+ 1
No it isn't😊