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

Do I need java for windows 10?

784


How can we find the actual size of an object on the heap?

1084


What is the use of callablestatement?

797


What is used of static keyword in java?

791


4.1 Supply contracts (in the form of comments specifying pre- and post conditions) for the enqueue() method of the LinkedQueue class given in the Appendix. (2) 4.2 Let Thing be a class which is capable of cloning objects, and consider the code fragment: Thing thing1 = new Thing(); //(1) Thing thing2 = thing1; //(2) Thing thing3 = (Thing) thing1.clone(); //(3) Explain how the objects thing2 and thing3 differ from each other after execution of the statements. (

1656


Can a static member function access member variable of an object?

792


How do you sort data in java?

743


What do you mean by boolean?

835


What is the basic of java?

797


What is java used for on a computer?

730


Which java collection does not allow null?

920


How can we access some class in another class in java?

781


How to change the priority of thread or how to set the priority of thread?

840


Will the compiler creates a default constructor if I have a parameterized constructor in the class?

832


What are the object and class classes used for?

809