book task

  1. Create a class called ‘Book’.
  2. Have below method in Book class. public void read(int page) { System.out.println(“No. of Pages ” + page); }
  3. Create one more class called ‘Reader’ with main method.
  4. Create instance for Book class now.
  5. 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 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 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); }

Enter fullscreen mode Exit fullscreen mode

}

public class Reader {
public static void main(String[] args)
{

Book physics = new Book();
physics.read(100);

}

}
out put —No. of Pages 100

原文链接:book task

© 版权声明
THE END
喜欢就支持一下吧
点赞11 分享
People do a lot of thinking, and sometimes, that's what kills us.
有时候是我们自己想太多才让自己如此难受
评论 抢沙发

请登录后发表评论

    暂无评论内容