DEV Community

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

Posted on

1

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)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs