Oracle
1Z0-815 · Question #98
Given: public class SampleClass { public static void main(String[] args) { AnotherSampleClass asc = new AnotherSampleClass(); SampleClass sc = new SampleClass(); sc = asc; System.out.println("sc: "…
The correct answer is D. sc: class AnotherSampleClass. See the full explanation below for the reasoning.
Question
Given:
public class SampleClass { public static void main(String[] args) { AnotherSampleClass asc = new AnotherSampleClass(); SampleClass sc = new SampleClass(); sc = asc; System.out.println("sc: " + sc.getClass()); System.out.println("asc: " + asc.getClass()); }} class AnotherSampleClass extends SampleClass { } What is the result?
Options
- Asc: class Object
- Bsc: class SampleClass
- Csc: class AnotherSampleClass
- Dsc: class AnotherSampleClass
How the community answered
(47 responses)- A11% (5)
- B4% (2)
- C4% (2)
- D81% (38)
Community Discussion
No community discussion yet for this question.