nerdexam
GIAC

GSSP-JAVA · Question #35

You write the following code. class Father {public void Method() {System.out.println("I am Father");}} public class Son extends Father {public static void main(String argv[]) {Son son = new…

The correct answer is E. A compile-time error will result. See the full explanation below for the reasoning.

Question

You write the following code. class Father {public void Method() {System.out.println("I am Father");}} public class Son extends Father {public static void main(String argv[]) {Son son = new Son();son.Method();} private void Method() {System.out.println("I am Son");}} Which of the following will be the result, when you try to compile and run the code?

Options

  • AI am Father will be displayed as the output.
  • BA runtime error will result.
  • CI am Son will be displayed as the output.
  • DThe code will execute but without displaying any output.
  • EA compile-time error will result.

How the community answered

(38 responses)
  • A
    3% (1)
  • B
    5% (2)
  • C
    3% (1)
  • D
    8% (3)
  • E
    82% (31)

Community Discussion

No community discussion yet for this question.

Full GSSP-JAVA Practice