DEV Community

hema latha
hema latha

Posted on

Tv task

  1. Create a class called TV
  2. Have below method in it. public void watch() { System.out.println("Watching TV"); }
  3. Save and Compile this class.
  4. Create another class called Viewer with main method.
  5. Inside main method, create an instance for TV class. (Instance - object)
  6. Using created instance, call watch() method.
    public class Tv {

    public static void main(String[] args) {
    // TODO Auto-generated method stub
    Tv LG = new Tv();
    LG.Watch();
    }
    public void Watch ()
    {
    System.out.println("watching tv");
    }
    }

public class Viewer {

public static void main(String[] args) {
    // TODO Auto-generated method stub
       Tv LG = new Tv();
       LG.Watch();

}
Enter fullscreen mode Exit fullscreen mode

}
out put watching tv

Top comments (0)

Image of Timescale

πŸ“Š Benchmarking Databases for Real-Time Analytics Applications

Benchmarking Timescale, Clickhouse, Postgres, MySQL, MongoDB, and DuckDB for real-time analytics. Introducing RTABench πŸš€

Read full post β†’

πŸ‘‹ Kindness is contagious

DEV shines when you're signed in, unlocking a customized experience with features like dark mode!

Okay