+91-85006-22255
Define a class WaterBottle with the attributes capacity, material, color, hasCap. There data types are double, String, String and boolean respectively.
WaterBottle
capacity
material
color
hasCap
double
String
boolean
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."); } }
Topic: Member Variable In Java
Read this topic Take test on this topic
Open In App