nerdexam
GIAC

GSSP-NET · Question #134

Mark works as a Software Developer for Mansoft Inc. He develops an application using Visual Studio .NET 2005. He writes the following code snippet in the application: public class MyClass { public…

The correct answer is A. The code snippet will compile successfully and the output will be displayed as "Finally". See the full explanation below for the reasoning.

Question

Mark works as a Software Developer for Mansoft Inc. He develops an application using Visual Studio .NET 2005. He writes the following code snippet in the application:

public class MyClass { public static void Main(String[] args) { try { return; } finally { Console.WriteLine("Finally"); } } } What will happen when Mark attempts to compile and execute the code snippet?

Options

  • AThe code snippet will compile successfully and the output will be displayed as "Finally".
  • BThe code snippet will compile successfully, but an exception message will be displayed at runtime.
  • CA compile-time error will occur because the catch block is not defined.
  • DThe code snippet will compile successfully, but nothing will be displayed as output on execu tion.

How the community answered

(30 responses)
  • A
    77% (23)
  • B
    13% (4)
  • C
    7% (2)
  • D
    3% (1)

Community Discussion

No community discussion yet for this question.

Full GSSP-NET Practice