Exam 1z0-809 All QuestionsBrowse all questions from this exam
Question 81

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?

    Correct Answer: D

    The Test.java file fails to compile because the method 'read' in the Book class is private. Private methods cannot be accessed from outside their class, and therefore the calls to 'b1.read' and 'b2.read' in the main method will result in a compilation error.

Discussion
InnovationOption: C

we cant call b1.read() from outside the class Book because it is private the code does not compile

SamriddjiOption: D

D tested. If the few typos are removed. In Ebook.java replace "public class String read (String url) { return "View" + url }" with "public String read (String url) { return "View" + url; }"

jduarteOption: C

Answer is C because public class String read (String url) { return "View" + url } not compile. If clear String in read then the answer is D because b1.read() can´t to access

asdfjhfgjuaDCVOption: D

Answer is D if Class is not there in ebook else C

steefaandOption: C

Given this code is correctly typed, answer is C since it contains line: public class String read If class is not there then answer is D since read method is private and can't be called from outside of class.

Svetleto13Option: D

If typo is corrected then answer should be D. public String read (String url)

thetechOption: C

Answer is C. Tested.