DEV Community

V I N O T H
V I N O T H

Posted on

Task 3

Task 3:

  1. Create a class called WaterBottle
  2. Have below method in it. public void drink() { System.out.println("Drinking Water"); }
  3. Save and Compile this class.
  4. Create another class called Boy with main method.
  5. Inside main method, create an instance for WaterBottle class.
  6. Using created instance, call drink() method.

Input:

Image description

Image description

Output:

Image description

Top comments (0)