Search Interview Questions
| 2679 questions in repository.|
There are more than 200 unanswered questions.
Click here and help us by providing the answer.
Have a video suggestion.
Click Correct / Improve and please let us know.
|Interview Questions and Answers for 'Berkley net' - 1 question(s) found - Order By Newest|
|Frequently asked to fresh graduates and less experienced developers. Among the first few questions in many interviews.|
|Ans. Composition - has-a relationship between objects.|
Inheritance - is-a relationship between classes.
Composition - Composing object holds a reference to composed objects and hence relationship is loosely bound.
Inheritance - Derived object carries the base class definition in itself and hence its tightly bound.
Composition - Used in Dependency Injection
Inheritance - Used in Runtime Polymorphism
Composition - Single class objects can be composed within multiple classes.
Inheritance - Single class can only inherit 1 Class.
Composition - Its the relationship between objects.
Inheritance - Its the relationship between classes.
Sample Code for inheritance
Sample Code for composition
|Help us improve. Please let us know the company, where you were asked this question :|
|Like Discuss Correct / Improve java java concepts inheritance composition inheritance vs composition HCL Technologies Tata Consultancy (TCS) Infosys Amazon Source Intelligence News UK Starmount MapQuest SalesForce Expedia Deegit JP Morgan Canva Todle Yodle Berkley Net Help Scout Partners HealthCare Doximity Commvault Heroku Starmount Help.com healthcare system TU Kaiserslautern basic   frequent|
Try 5 Question(s) Test
|Difference between Composition and Inheritance ?|
| Which of the following Java feature promotes access protection or Hiding ?|
|Which of the following is tightly bound ? Inheritance or Composition ?|
|Can we compose the Parent Class object like this ?|
|Which of the following Java features facilitates Dependency Injection - Inheritance or Composition ?|
|How are the concept of Association related to Composition and Inheritance ?|
|Is dependency injection possible if we don't have inheritance / Composition ?|
|What is composition ?|
|Does use of Final class enforces composition over Inheritance in Java ?|