Multiple Choice Question

Quiz Guidelines



Consider the following class definition:

public class TestClass{
public static void main(){ new TestClass().sayHello(); } //1
public static void sayHello(){ System.out.println("Static Hello World"); public void sayHello() { System.out.println("Hello World "); } //3

What will be the result of compiling and running the class?

Select 1 option

A. It will print Hello World.
B. It will print Static Hello World.
C. Compilation error at line 2.
D. Compilation error at line 3.
E. Runtime Error.

Q&A Set: