Menu
Question Index
...

Define a class Room with attributes length and width. These attributes are of type double. Define a constructor to take these parameters. Also define a method getArea() to get the area of the room.



class FindRoomArea
{
    public static void main(String s[])
    {
        Room dining = new Room(12.5, 3.45);
        
        System.out.println("The area of dining room with width " + dining.width + " and length " + dining.length + " is " + dining.getArea() + ".");

    }



}
class Room
{
}

Doubts

Problems

Topic: Behavior Of Java Classes Using Methods

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App