-
What is the output of this program?
final class n
{
int K;
}
class n1 extends n
{
int L;
System.out.println(L + " " + K);
}
public class inheritance_Example
{
public static void main(String args[])
{
n1 obj = new n1();
obj.display();
}
}
-
- Runtime Error
- 4 4
- Compilation Error
- 5 5
- None of these
Correct Option: C
class n has been declared final hence it cannot be inherited by any other class. Hence class B does not have member i, giving compilation error.
Output: Compilation Error