When we will use an Interface and Abstract class?

Answer Posted / manoshp

Abstract class:- When there are common behaviors for a set of classes and that behavior do not have any existence by its own, these behaviors are defined in an abstract super class. All sub classes will inherit that common behavior by extending the super class.

Interface:- When there are multiple implementations for a set of functionalities, all these behaviors are defined in an interface as entry points without any implementation details to these behaviors. The client class can use this interface without considering the implementation details.

Is This Answer Correct ?    6 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain about version control?

593


What do you mean by mnemonics?

534


What are desktop procedures?

561


Why webdriver is an interface?

582


What is the purpose of main function in java?

539






Differences between external iteration and internal iteration?

577


Write a program to print fibonacci series

613


What are singleton services?

493


Explain about main() method in java ?

585


Why is an interface be able to extend more than one interface but a class can’t extend more than one class?

707


How to retrieve data from database in java using arraylist?

530


What does java edition mean?

537


Explain the different forms of polymorphism?

569


What are abstract methods in java?

655


What is difference between c++ and java ?

671