Login with  Log in with facebook
Hiring Manager? SIGN UP HERE

When I gave the java paper of Q1A site Then this question came.

I don't know that what is actual answer of this question.

This question may have answer's.

1. Inheritance

2. Interface

3.  Composition

4.  Aggregration


What is Composition in java ?

Atul Kumar Goyal
09/14/2011 at 04:16
1 Answer

There are two ways to relate classes: inheritance and composition.

Inheritance: when class A is related to class B by inheritance, because A extends B.
class B {

class A extends B {


Composition: Instance variables that are references to other objects. For example:

class B {

class A {
    private B b = new B();  

Now you can find out about advantages/disadvantages of both the ways...

Sudhir Jangir
09/14/2011 at 05:43

If you want to post any answer to this forum then you need to log in.
Schedule a Demo

Schedule a Demo with us

Name *
Email *
Phone *
Company *