What will be the output of the following program?
public class Cloning {
public static void main(String[] args) {
Book myBook = new Book(170, "Sherlock Holmes");
Book xerox = (Book) myBook.clone();
System.out.println("Book name " + xerox.bookName + " and price is " + xerox.price + ".");
}
}
class Book {
public Book(int price, String bookName) {
this.price = price;
this.bookName = bookName;
}
String author;
int price;
String bookName;
protected Object clone() {
try {
return super.clone();
} catch (CloneNotSupportedException e) {
System.out.println("Don't do xerox buy it");
return this;
}
}
}