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();
        r.name = "Hall";
        r.flooring = "Marble";
        r.width = r.height = 12;
        r.fan = new Fan();
        r.fan.speed = 1500;
        r.fan.color = "Brown";
        r.fan.numberOfWings = 3;
        System.out.println(r.fan.speed + r.fan.color + r.fan.numberOfWings);
        System.out.println(r.name + r.flooring + r.width + r.height);
    }
    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;    
}


1500.0Brown4
HallItalianMarble1225
1500.0Brown3
HallMarble1212
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