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

If system.exit (0); is written at the end of the try block, will the finally block still execute?

848


what is the final keyword denotes in java?

806


Explain covariant method overriding in java.

796


How does arraylist size increase in java?

793


What is an array length?

700


Define reflection.

763


Explain how hashmap works?

822


what is the difference between process and thread? : Java thread

789


What is java life cycle?

771


What is the difference between private & public & friendly classes?

807


Why charat is used in java?

830


What's the purpose of static methods and static variables?

823


How do I enable java in safari?

790


What is the difference between delete and delete[]

965


Explain about features of local inner class?

841