Java
T
point
Home
Python
Java
JavaScript
HTML
SQL
PHP
C#
C++
DS
Aptitude
Reasoning
Selenium
DBMS
C
Android
Interview Q
Content Menu ▼
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Question 1
:
class A{
void foo() throws Exception { throw new Exception(); }
}
class SubB2 extends A {
void foo() { System.out.println("B "); }
}
class Tester {
public static void main(String[] args) {
A a = new SubB2();
a.foo();
}
}
What is the result?
1.
B
2.
B, followed by an Exception.
3.
Compilation fails due to an error on line 9.
4.
Compilation fails due to an error on line 14.