ProgrammingModerateTCS NQT · Infosys pattern

What is printed?

What is printed?
try {
    System.out.print("T");
    throw new RuntimeException();
} catch (Exception e) {
    System.out.print("C");
} finally {
    System.out.print("F");
}
  1. A. TCF
  2. B. TC
  3. C. TF
  4. D. TFC

Correct answer: A. TCF

T prints, the exception is thrown, the catch for Exception handles it (C), and finally always runs last (F).

More OOP with C++ and Java questions

Exams that ask this topic