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

What is floor in java?

550


What is the synonym of framework?

555


When would you use a static class?

572


Which is better singleton or static class?

499


What is the largest data type in java?

504






Which software is used for java programming?

546


Explain the difference between abstract classes and interfaces in java?

592


Can a constructor call the constructor of parent class?

528


Is linked list a linear or non-linear data structure?

537


Do I need java on my pc?

503


What is meant by object oriented programming – oop?

535


When to use runnable interface vs thread class in java?

514


What is blank final variable?

557


How are variables stored in memory?

570


Can we declare the main method of our class as private?

546