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");
}- A. TCF
- B. TC
- C. TF
- 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
- Why must a C++ copy constructor take its parameter by reference (A(const A &other)) rather than by value?
- What is printed? java System.out.print("placement".substring(2, 5) + "placement".indexOf('e'));
- What is the time complexity of get(i) on a Java ArrayList and on a LinkedList?
- In C++, what does new do that malloc does not?
- What is printed? java class A { void show() { System.out.print("A"); } } class B extends A { void show() { super.show()…
- What is printed? cpp class Base { public: void show() { cout << "B1"; } virtual void vshow() { cout << "B2"; } }; class Derived : public…