Menu
Question Index
...

Define the class Chair with the attributes backSupport, material, color, revolving, price. There data types are boolean, String, String, boolean, double respectively.



class DefineChairClass
{
    public static void main(String s[])
    {
        Chair c = new Chair();
        c.material = "Plastic";
        c.color = "Sky Blue";
        c.price = 243.5;
        c.backSupport = true;
        c.revolving = false;
        
        System.out.println(c.color + " " + c.material + " chair's cost is Rs. " + c.price + ".");
        System.out.print("It has " + (c.backSupport ? "" : "no ") + "back support. ");
        System.out.println("It is " + (c.revolving ? "" : "not ") + "a revolving chair.");

    }



}

Doubts

Problems

Topic: Member Variable 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