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 / gkp

Abstract class and Interface are the design time decision. As we expect to extend our implementation in future so we need to give space to incorporate new implementation. As we know if some implementation of a method will be common in many classes then that method should be moved to abstract class so the repetition of same code can be avoided. Even though we don't have any abstract method in our abstract class, we can go for a abstract class. Generally in design of java classes, it is designed like, first an interface then an abstract class and then concrete class implementation starts.

Is This Answer Correct ?    5 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to reverse string in java?

617


Make a data structure and implement an algorithm to print all the files in a directory. (The root directory can have sub-directories too.)

857


What are the differences between throw and throws?

532


Give reasons supporting that string is immutable.

499


what is recursion in java

600






What are constructors in java?

574


Which sorting algorithm is best in java?

537


what invokes a threads run() method? : Java thread

574


What is the super void?

461


How is hashcode calculated in java?

505


What are the 2 types of java programs?

565


What is mean by collections in java?

564


Explain about varargs in java?

583


What is nested interface?

524


How many ways can an argument be passed to a subroutine and explain them?

579