Menu
Question Index
...

Define a class WaterBottle with the attributes capacity, material, color, hasCap. There data types are double, String, String and boolean respectively.



class DefineWaterBottleClass
{
    public static void main(String s[])
    {
        WaterBottle waterBottle = new WaterBottle();
        waterBottle.capacity = 1.25;
        waterBottle.material = "Plastic";
        waterBottle.color = "Pink";
        waterBottle.hasCap = true;
        System.out.println( waterBottle.color + " water bottle made of " + waterBottle.material + " has a capacity of " + waterBottle.capacity + " liters.");

    }



}

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