Oracle
1Z0-851 · Question #140
1Z0-851 Question #140: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-851 to reveal the answer and full explanation for question #140. The question stem and answer options stay visible for context.
Question
Given: interface Fish { } class Perch implements Fish { } class Walleye extends Perch { } class Bluegill { } public class Fisherman { public static void main(String[] args) { Fish f = new Walleye(); Walleye w = new Walleye(); Bluegill b = new Bluegill(); if(f instanceof Perch) System.out.print("f-p "); if(w instanceof Fish) System.out.print("w-f "); if(b instanceof Fish) System.out.print("b-f "); } } What is the result?
Options
- Aw-f
- Bf-p w-f
- Cw-f b-f
- Df-p w-f b-f
- ECompilation fails.
- FAn exception is thrown at runtime.
Unlock 1Z0-851 to see the answer
You've previewed enough free 1Z0-851 questions. Unlock 1Z0-851 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.