Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.56 KB | None | 0 0
  1. /*
  2.  * This is called BookSameName as it is showing the use of using methods
  3.  * with the same name on inherited methods. The only difference between
  4.  * this and Book is that putBook() is called put() here.
  5.  */
  6. class BookSameName
  7. {
  8.     private String author, title;                                           // initialises the autor and title
  9.    
  10.     BookSameName(String author0, String title0)                                     // constructor
  11.     {
  12.         author = author0;
  13.         title = title0;
  14.     }
  15.  
  16.     void put()                                                  // print method, this time put() instead of putBook()
  17.     {
  18.         System.out.println(title + " by " + author);
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement