We use extends keyword for using is-a relationship in Java using OOP. But on the other side, we also have has-a relationship and we use reference of the first class in 2nd class for has-a relationship. My question is, if we have a has-a relationship, can we use extends keyword in implementation?
Suppose we have the example here:
A “university” has several “departments”. Without the existence of “university”, there is no chance for the “departments” to exist.
Can we write it as (just a rough example for understanding)
class University extends Department
{
   Department d = new Department();
   University(String name, Department d)
    {
        this.Name=name;
        this.Department = d;    
    }    
}
or when we make an entity of one class in another we can not use word extends?
 
     
     
    