How to decide whether use IS A or HAS A Relation

Viewed 18603
public class B {

    public String getMe()
    {
        return "Some";
    }
}

Assume that i have a above class , by which parameters should we decide what to use ?? Whether is a or Has a Relation ??

HAS - A

public class A {



    public static void main(String args[])
    {
        B b = new B();
        System.out.println(b.getMe());
    }
}

or

public class A  extends B
{


    public static void main(String args[])
    {
        A b = new A();
        System.out.println(b.getMe());
    }
}
4 Answers
Related