ProgrammingModerateTCS NQT · Infosys pattern
Which of these is a checked exception in Java?
- A. IOException
- B. ArrayIndexOutOfBoundsException
- C. ArithmeticException
- D. NullPointerException
Correct answer: A. IOException
Checked exceptions extend Exception but not RuntimeException, and the compiler forces you to catch or declare them; IOException is one. The other three extend RuntimeException and are unchecked.
More OOP with C++ and Java questions
- A parent class declares protected void run(). Which overriding declaration in a subclass compiles?
- Parent declares void read() throws IOException. Which override in a subclass compiles?
- What is printed? java Set<String> t = new TreeSet<>(List.of("apple", "Banana", "cherry")); System.out.print(t);
- What happens when this Java code is compiled? java class P { P(int x) { } } class C extends P { C() { } }
- What is printed? java // static methods of the main class: static void f(int... a) { System.out.print("V"); } static void f(int a, int b)…
- Which member function fails to compile? cpp class C { int a = 0; mutable int hits = 0; public: int get() const { hits++; return a; } void…