Compostion should be preferred over inheritance and should be used if the classes don't have a parent -child relationship.
So in the example below we see we can make a Room constructor and in that we pass objects of classes like wall,ceiling and lamp.
And since we have a getter method in Room that returns an lamp what we can do is use that lamp object to access method turnOn of lamp class.
So point is Room can't extend lamp class but we can use its object to access its methods like we did here
bedroom1.getLamp().turnOn();
So in the example below we make objects of various classes in a main class
And all these objects are passed into constructor of Room class and room class will then use these objects to access methods of these classes
public static void main(String[] args) {
Wall wall1 = new Wall("east");
Wall wall2 = new Wall("west");
Wall wall3 = new Wall("north");
Wall wall4 = new Wall("south");
Ceiling ceiling = new Ceiling(50,"blue");
Bed bed = new Bed(4,"brown",2);
Lamp lamp = new Lamp("velvet",true);
Rom room1 = new Room("My bedroom",wall1,wall2,wall3,wall4,ceiling,bed,lamp);
room1.getLamp().turnOn();