nerdexam
GIAC

GSSP-JAVA · Question #226

John works as a Software Developer for VenTech Inc. He writes the following code using Java. public class vClass extends Thread { public static void main(String args[]) { vClass vc=new vClass()…

The correct answer is D. The application will compile successfully but will not display anything as the output. See the full explanation below for the reasoning.

Question

John works as a Software Developer for VenTech Inc. He writes the following code using Java. public class vClass extends Thread { public static void main(String args[]) { vClass vc=new vClass(); vc.run(); } public void start() { for(int k=0;k<20;k++) { System.out.println("The value of k = "+k); } } } What will happen when he attempts to compile and execute the application?

Options

  • AThe application will compile successfully and the values from 0 to 19 will be displayed as
  • BA compile-time error will occur indicating that no run() method is defined for the Thread
  • CA runtime error will occur indicating that no run() method is defined for the Thread class.
  • DThe application will compile successfully but will not display anything as the output.

How the community answered

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

Community Discussion

No community discussion yet for this question.

Full GSSP-JAVA Practice