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

Explain the use of shift operator in java. Can you give some examples?

739


Difference between string, stringbuffer and stringbuilder?

820


What is indexof?

735


What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?

874


How do you clear a list in java?

815


Explain implementation and how is it different from conversion?

809


What is the purpose of stub and skeleton?

764


Explain importance of throws keyword in java?

774


Explain about the main() method in java?

811


Is 64bit faster than 32 bit?

821


What is method with example?

796


What is a cup of java?

797


What is the difference between call by reference and call by pointer?

729


What is temp in java?

782


What is a native method in java programming?

760