what is difference between abstract and interface?
can i give real time example for the two topics?

Answer Posted / lakshmi

Interface has no implementation, but they have to be
implemented.
Abstract class’s methods can have implementations and they
have to be extended.
Interfaces can only have method declaration (implicitly
public and abstract) and fields (implicitly public static)
Abstract class’s methods can’t have implementation only
when declared abstract.
Interface can inherit more than one interfaces
Abstract class can implement more than one interfaces, but
can inherit only one class
Abstract class must override all abstract method and may
override virtual methods
Interface can be used when the implementation is changing
Abstract class can be used to provide some default behavior
for a base class.
Interface makes implementation interchangeable
Interface increase security by hiding the implementation
Abstract class can be used when implementing framework
Abstract classes are an excellent way to create planned
inheritance hierarchies and also to use as non-leaf classes
in class hierarchies.

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to find the given number is a prime number or not by getting input from the user

773


What is difference between null and void?

731


Can we declare a constructor as final?

912


String class is defined under which package in java?

818


Can you declare a private method as static?

911


How do you calculate square roots?

856


What do you mean by exception handling in Java?

985


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

728


What does singleton mean in java?

723


Which class contains a method: cloneable or object?

766


Explain creating threads by extending thread class ?

772


What is collection api?

813


What is the purpose of static methods and static variables?

756


Can we nested try statements in java?

856


Why 1 is not a prime number?

788