Oracle
1Z0-851 · Question #79
1Z0-851 Question #79: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-851 to reveal the answer and full explanation for question #79. The question stem and answer options stay visible for context.
Question
Given two files, GrizzlyBear.java and Salmon.java: 01. package animals.mammals; 02. 03. public class GrizzlyBear extends Bear { 04. void hunt() { 05. Salmon s = findSalmon(); 06. s.consume(); 07. } 08. } 01. package animals.fish; 02. 03. public class Salmon extends Fish { 04. public void consume() { /* do stuff */ } 05. } If both classes are in the correct directories for their packages, and the Mammal class correctly defines the findSalmon() method, which change allows this code to compile?
Options
- Aadd import animals.mammals.*; at line 2 in Salmon.java
- Badd import animals.fish.*; at line 2 in GrizzlyBear.java
- Cadd import animals.fish.Salmon.*; at line 2 in GrizzlyBear.java
- Dadd import animals.mammals.GrizzlyBear.*; at line 2 in Salmon.java
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.