Task 3:
- Create a class called WaterBottle
- Have below method in it. public void drink() { System.out.println("Drinking Water"); }
- Save and Compile this class.
- Create another class called Boy with main method.
- Inside main method, create an instance for WaterBottle class.
- Using created instance, call drink() method.
Input:
Output:
Top comments (0)