11. static class A {
12. void process() throws Exception { throw new Exception();
}
13. }
14. static class B extends A {
15. void process() { System.out.println(”B”); }
16. }
17. public static void main(String[] args) {
18. new B().process();
19. }
What is the result?
1 B
2 The code runs with no output.
3 Compilation fails because of an error in
line 12.
4 Compilation fails because of an error in
line 15.
Answer Posted / bhanu
hi,
Keep the whole code in a class
Ex:
class Sample
{
.....
..... //the above code
.....
.....
}
Now it will not give any error while compilation.
It is the concept of static nested classed
Thank you
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Difference between current previous versions of Java?
Is linkedlist thread safe in java?
What is structure of java heap? What is perm gen space in heap?
What is a substitution variable?
What is empty string literal in java?
How to sort numbers in java without array?
What is constructor in java ?
How many JVMs can run on a single machine and what is the Just-In-Time(JIT) compiler?
How do you do math powers in java?
How variables are declared?
What is string intern in java?
What is an immutable class? How to create an immutable class?
What are jee technologies?
What is the purpose of methodology?
Why is it called boolean?