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
Do I need java for windows 10?
How can we find the actual size of an object on the heap?
What is the use of callablestatement?
What is used of static keyword in java?
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. (
Can a static member function access member variable of an object?
How do you sort data in java?
What do you mean by boolean?
What is the basic of java?
What is java used for on a computer?
Which java collection does not allow null?
How can we access some class in another class in java?
How to change the priority of thread or how to set the priority of thread?
Will the compiler creates a default constructor if I have a parameterized constructor in the class?
What are the object and class classes used for?