What is the result?

Given:
Book.java:
public class Book {
private String read(String bname) { return “Read” + bname }
}
EBook.java:
public class EBook extends Book {
public class String read (String url) { return “View” + url }
}
Test.java:
public class Test {
public static void main (String[] args) {
Book b1 = new Book();
b1.read(“Java Programing”);
Book b2 = new EBook();
b2.read(“http://ebook.com/ebook”);
}
}
What is the result?

Given:
Book.java:
public class Book {
private String read(String bname) { return “Read” + bname }
}
EBook.java:
public class EBook extends Book {
public class String read (String url) { return “View” + url }
}
Test.java:
public class Test {
public static void main (String[] args) {
Book b1 = new Book();
b1.read(“Java Programing”);
Book b2 = new EBook();
b2.read(“http://ebook.com/ebook”);
}
}
What is the result?

A.
Read Java Programming
View http:/ ebook.com/ebook

B.
Read Java Programming
Read http:/ ebook.com/ebook

C.
The EBook.java file fails to compile.

D.
The Test.java file fails to compile.



Leave a Reply 5

Your email address will not be published. Required fields are marked *


smh

smh

A or B.

ReadJava Programing
Readhttp://ebook.com/ebook

MickB

MickB

Answer is D method read has private access modifier in class Book.java and both b1 and b2 are of reference type Book so compiler checks there first.

smh

smh

Yes MickB is right.
D. The Test.java file fails to compile.

Berti John

Berti John

D. is correct