There can be a abstract class without abstract methods, but
what is the need to declare a class abstract if it doesn't
contain abstract methods?

Answer Posted / ram

We will get an additional facility in using abstract classes over interfaces is, in abstract class if we add a new method, in its child classes we need not implement those newly added methods as it is non-abstract method and has default implementation in the abstract class definition. But whereas if we add a new method (abstract) in the interface, in all its implemented classes needs to implement this newly added method which leads to many changes which is violating one of the design principle – Open for extension Closed for modification.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is javac used for?

720


Can you pass by reference in java?

754


Differences between external iteration and internal iteration?

895


What is difference between next () and nextline () in java?

792


What is string in java with example?

724


What are different type of exceptions in java?

765


How do you start a thread?

796


Java Compiler is stored in JDK, JRE or JVM?

1268


Name some classes present in java.util.regex package.

835


Write a program to print 15 random numbers using foreach of java 8?

763


Is Java a dying language?

839


What restrictions are placed on method overloading?

905


Convert Binary tree to linked list.

859


What is final method in java?

777


Explain why wait(), notify() and notifyall() methods are in object class rather than in the reading class?

789