DEV Community

hema latha
hema latha

Posted on

Library Task

  1. create a class called - Library
  2. Have a main method in it
  3. Inside main method object creation instance called book
  4. using book reference call method read(300);
  5. In read (int pages)method return pages
  6. store return value as pa
  7. print pa in main method

package terminaltask;

public class Library {

public static void main(String[] args) {
    // TODO Auto-generated method stub
Enter fullscreen mode Exit fullscreen mode

Library book = new Library();
int pa = book.read(300);
System.out.println(pa);
}
public int read(int pages)
{
return pages;
}
}

out put --300

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more