Menu
Question Index
...

What will be the output of the following program?

public class RoomAndFan {
    public static void main(String[] args) {
        Room r = new Room();
        Fan f = new Fan();
        r.name = "Hall";
        r.flooring = "Marble";
        r.width = r.height = 12;
        f.speed = 1500;
        r.fan.color = "Brown";
        r.fan.numberOfWings = 3;
        System.out.print(r.name + r.flooring + r.width + r.height);
        System.out.print(r.fan.speed + r.fan.color + r.fan.numberOfWings);
    }
}
class Room {
    String name;
    String flooring;
    int width, height;
    Fan fan = new Fan();
}
class Fan {
    double speed;
    String color;
    int numberOfWings;
}


HallMarble12120.0Brown3
HallMarble241500.0Brown3
HallMarble12121500.0Brown3
Compilation Error or Runtime Error

Doubts

Problems

Topic: Calling A Class From Another Class In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App