exam questions

Exam 1z0-808 All Questions

View all questions & answers for the 1z0-808 exam

Exam 1z0-808 topic 1 question 116 discussion

Actual exam question from Oracle's 1z0-808
Question #: 116
Topic #: 1
[All 1z0-808 Questions]

Given the code fragments:

What is the result?

  • A. Compilation fails only at line n2.
  • B. RTool::export Tool::export
  • C. Tool::export Tool:export
  • D. Compilation fails only at line n1.
  • E. Compilation fails at both line n1 and line n2.
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
letmein2
Highly Voted 4 years, 3 months ago
D. By default, method declaration in an interface is implicitly Public abstract. Overiding with protected is a more restrictive access modifier.
upvoted 21 times
...
amit_lad88
Most Recent 3 days, 21 hours ago
Correct Answer is D. Reason: "Cannot reduce the visibility of the inherited method from Exportable interface"
upvoted 1 times
...
akbiyik
1 year ago
Selected Answer: D
All abstract, default, and static methods in an interface are implicitly public. void export() has not a package-private access. It is implicitly public. Answer is D. The other typo are not delibarely generated I think.
upvoted 1 times
...
carloswork
1 year, 1 month ago
Selected Answer: D
Answer is D. "Tool::export" is printed and java.lang.IllegalAccessError error is thrown. Although there is a print on the terminal, this error is classified as a compilation error, according to oracle documentation. https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalAccessError.html To test: interface Exportable { void export(); } class Tool implements Exportable { protected void export () { // line n1 - throwIllegalAccessError System.out.println("Tool::export"); } } class ReportTool extends Tool implements Exportable { public void export () { // line n2 System.out.println("RTool::export"); } public static void main(String[] args) { Tool aTool = new ReportTool(); Tool bTool = new Tool(); callExport(aTool); callExport(bTool); } public static void callExport (Exportable ex) { ex.export(); } }
upvoted 2 times
...
Winston123
1 year, 6 months ago
Selected Answer: D
ANS: D The implicitly default access modifier in the interface can only be public, thus couldn't overrding with the protected access modifer
upvoted 1 times
...
lnrdgst
1 year, 10 months ago
Guys, in my case, testing here at bluej, I verified that the problem is in the interface, marking the Void with a capital v, in this case, the compilation of line n1 and n2 fails. So what convinced me the most was the answer "E".
upvoted 4 times
ManuTov
3 months, 3 weeks ago
Void (uppercase): It is a class in Java that is part of the java.lang package. It is used as a generic type to indicate that a generic method doesn't return any value. It is typically used in contexts where generic types are needed, such as in Callable<Void> or in generic classes that can work with different data types, including Void. It should not be confused with the use of void in method signatures.
upvoted 1 times
...
...
Surendra88
2 years, 4 months ago
Answer - D Access modifier of the implementation method in child class either has to be same or higher. In this scenario public. NOT protected. public void export(){ System.out.println("Tool: Export"); }
upvoted 1 times
...
sarou89
2 years, 8 months ago
agreed D tested
upvoted 1 times
...
onyddimmav4576
3 years ago
Compilaion error on Interface. Syntax error on Void
upvoted 1 times
...
SamAru
3 years, 5 months ago
Agreed, answer is D
upvoted 1 times
...
rasifer
4 years, 5 months ago
Answer is D, tested.
upvoted 4 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago