nerdexam
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)
  • A
    11% (5)
  • B
    4% (2)
  • C
    4% (2)
  • D
    81% (38)

Community Discussion

No community discussion yet for this question.

Full 1Z0-815 Practice