Oracle
1Z0-819 · Question #33
Given: class Super { static String greeting() { return "Good Night"; } String name() { return "Harry"; } } and class Sub extends Super { static String greeting() { return "Good Morning"; } String…
The correct answer is B. Good Morning, Harry. See the full explanation below for the reasoning.
Question
Given:
class Super {
static String greeting() { return "Good Night"; }
String name() { return "Harry"; }
}
and
class Sub extends Super {
static String greeting() { return "Good Morning"; }
String name() { return "Potter"; }
}
and
class Test {
public static void main(String[] args) {
Super s = new Sub();
System.out.println(s.greeting() + " , " + s.name());
}
}
What is the result?
Options
- AGood Morning, Potter
- BGood Morning, Harry
- CGood Morning, Harry
- DGood Night, Harry
How the community answered
(42 responses)- A2% (1)
- B81% (34)
- C7% (3)
- D10% (4)
Community Discussion
No community discussion yet for this question.