OCJP Preparation - Java Inner Classes - BEHIND JAVA

OCJP Preparation - Java Inner Classes

Share This

1. Given the program

What is the output?

  • A. 2
  • B. 3
  • C. 1 2
  • D. 2 3
  • E. 1 2 3
  • F. Compilation fails.
  • G. An exception is thrown at runtime.

Given the command line java Test:

2. What become the output?

  • A. Compilation fails.
  • B. An exception is thrown at runtime.
  • C. doStuff x = 6 main x = 6
  • D. doStuff x = 6 main x = 7
  • E. doStuff x = 7 main x = 6
  • F. doStuff x = 7 main x = 7

3. Given the program

What become the output?

  • A. Compilation fails.
  • B. An exception is thrown at runtime.
  • C. doStuff x = 6 main x = 6
  • D. doStuff x = 5 main x = 5
  • E. doStuff x = 5 main x = 6
  • F. doStuff x = 6 main x = 5

4. Given the program

What become the output?

  • A. 1
  • B. 2
  • C. Compilation fails.
  • D. The code runs with no output.
  • E. An exception is thrown at runtime.

5. Given the program

What become the output?

  • A. null
  • B. life
  • C. universe
  • D. everything
  • E. Compilation fails.
  • F. An exception is thrown at runtime.

6. Given the program

Which, inserted independently at line 5, will compile? (Choose all that apply.)

  • A. b = (Number instanceof s);
  • B. b = (s instanceof Short);
  • C. b = s.instanceof(Short);
  • D. b = (s instanceof Number);
  • E. b = s.instanceof(Object);
  • F. b = (s instanceof String);

No comments:

Post a Comment

Pages