Oracle
1Z0-819 · Question #56
1Z0-819 Question #56: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-819 to reveal the answer and full explanation for question #56. The question stem and answer options stay visible for context.
Question
Given
public class Hello {
class Greeting {
void sayHi() {
System.out.println("Hello world");
}
}
public static void main(String[] args) { // Line 1
}
}
What code must you insert on Line 1 to enable the code to print Hello world?
Options
- AA. Hello.Greeting myG = new Hello.Greeting().myG.sayHi();
- BB. Hello myH = new Hello(); Hello.Greeting myG = myH.new Greeting(); myG.sayHi();
- CC. Hello myH = new Hello(); Greeting myG = myH.new Greeting(); myG.sayHi();
- DD. Hello myH = new Hello(); Greeting myG = new Greeting(); myG.sayHi();
Unlock 1Z0-819 to see the answer
You've previewed enough free 1Z0-819 questions. Unlock 1Z0-819 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.