Menu
Question Index
...

What will be the output of the following program?

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

    public static void a(Room r)
    {
        r.flooring = "Italian " + r.flooring;
        r.height = (r.width + 12 + 1);
        r.fan.numberOfWings = 4;
    }
}

class Room { String name; String flooring; int width, height; Fan fan; }
class Fan { double speed; String color;    int numberOfWings; }


HallMarble241500.0Brown3
HallItalian Marble371500.0Brown4
HallMarble12121500.0Brown3
Compilation Error
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