DEV Community

AmalaReegan
AmalaReegan

Posted on

Day8

Ques:
**

  1. Create a class Library'
  2. Have main method in it.
  3. Inside main method, create an instance called'book'. 4, Usung'book', reference, call a method called' read (300).
  4. In read (int pages) method, return pages. 6 Store returned values as pa
  5. Print pa in main method.**

Input:

public class Library
{
public static void main(String[]args)
{
Library book=new Library();
book.read();
book.page(300);
}
public void read()
{
System.out.println("read");
}
public void page(int no1)
{
System.out.println(300);
}
}
Enter fullscreen mode Exit fullscreen mode

Output:

Image description

Top comments (0)