- create a class called - Library
- Have a main method in it
- Inside main method object creation instance called book
- using book reference call method read(300);
- In read (int pages)method return pages
- store return value as pa
- print pa in main method
package terminaltask;
public class Library {
public static void main(String[] args) {
// TODO Auto-generated method stub
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)