+ 2

Is it mandatory to have only abstract methods in an abstract class?

25th Dec 2017, 8:45 AM
Hope
Hope - avatar
4 Respostas
+ 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.
25th Dec 2017, 9:10 AM
GAWEN STEASY
GAWEN STEASY - avatar
+ 2
Thank you guys for answering my question 😊😊
18th Jan 2018, 5:41 PM
Hope
Hope - avatar
+ 1
No it isn't😊
25th Dec 2017, 9:04 AM
Jonas Schröter
Jonas Schröter - avatar