- Create a class called 'Book'.
- Have below method in Book class. public void read(int page) { System.out.println("No. of Pages " + page); }
- Create one more class called 'Reader' with main method.
- Create instance for Book class now.
- Using your instance, call read() method and pass 100 as argument.
public class Book {
public static void main(String[] args) {
// TODO Auto-generated method stub
Book physics = new Book();
physics.read(100);
}
public void read(int page)
{
System.out.println("No. of Pages " + page);
}
}
public class Reader {
public static void main(String[] args)
{
Book physics = new Book();
physics.read(100);
}
}
out put ---No. of Pages 100
Top comments (0)