class A
{
}
class B extend A
{
int i;
int j;
}
Can a class have an IS-A Relationship with itself?
In this question, B is an A, right?
But can class B
have an IS-A relationship with class B
?
class A
{
}
class B extend A
{
int i;
int j;
}
Can a class have an IS-A Relationship with itself?
In this question, B is an A, right?
But can class B
have an IS-A relationship with class B
?
It's an identity (and tautology) - an object of type B
will always be able to describe itself as an object of type B
.
The further extensions of the is-a relationship pertain to hierarchies of inheritance; that is to say, since B extends A
, B
is-an A
. This allows you to write the following expression:
A anA = new B();
But B
is a B
too. It hasn't lost that part of its identity because it now inherits from another class.