INTERVIEW QUESTIONS
J2EE
CORE JAVA
DETAILS
Question: what is main purpose of interface?
Answer: There is no multiple inheritance in java,we can't extends more than one class at a time,so interface is a way to implement multiple inheritance in java, and from design point view when we have some class specific behaviours we can put interface as a base of the classes.
|
Question:
what is main purpose of interface?
Answer:
There is no multiple inheritance in java,we can't extends more than one class at a time,so interface is a way to implement multiple inheritance in java, and from design point view when we have some class specific behaviours we can put interface as a base of the classes. Source: CoolInterview.com
Interface is essentially a contract (method signatures) of a component (the implementing object) which is offered to its users (method callers). The component itself may be from a third party. The users only need to know just the contract (method signatures). At a later stage if the component needs to be replaced by somthing else, for whatever reason, we can easily plug the other component which is offering the same contract (implementing the same interface) with no changes to the users (callers). I think this is the main advantage of having interfaces. Source: CoolInterview.com
Answered by: Veeranjaneyulu Sivaratri | Date: 5/26/2010
| Contact Veeranjaneyulu Sivaratri
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|