What is composition?

What is composition?

Composition is a design technique that establishing relationships between classes. There are two fundamental ways to relate classes : inheritance and composition. Composition is an alternative way of inheritance to ralate classes. 
Example :

class Fruit {

    //...
}

class Mango {

Fruit fruit = new Fruit();
    //...
}

By:Jalees
Date:2016-01-09 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related Java Subjective Links

Java Subjective interview questions and answers for experienced and fresher