What is the difference between abstract class and interface?

Answer Posted / ranganathkini

An interface is purely contractual in that it only defines
method headers but no implementation. Classes that implement
the interface must provide implementation to all method
defined by the interface.

An abstract class contains partial implementation, i.e. it
provides implementation for some methods where as just
defines abstract method headers for other. Abstract classes
cannot be instantiated directly and have to be extended by
subclasses who implement the abstract methods defined in the
abstract superclass. Unlike an interface, subclasses of the
abstract class only need to implement only those methods
that are marked abstract.

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of parseint in java?

762


Are registers volatile?

710


What is operator overloading. Is it is supported in java?

727


Why do I need to declare the type of a variable in java?

777


Is java programming easy?

742


Is there any case when finally will not be executed?

724


What is primitive array?

685


What is a conditional statement explain with example?

764


Program to Find the second largest element in an array.

818


What is numeric function?

726


Which collection is sorted in java?

786


What are the different types of collections in java?

735


What is string manipulation?

715


What are the basic control structures?

723


What do you understand by an io stream?

799