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 / r.jainrocks@gmail.com
Compilation fails
static keyword not allowed here
at line 11 and 14
| Is This Answer Correct ? | 9 Yes | 3 No |
Post New Answer View All Answers
Can we overload the methods by making them static?
Is java a security risk?
What are the two environment variables that must be set in order to run any java programs?
When would you use a static class?
What is data object example?
What is unicode full form?
Write a program to find maximum and minimum number in array?
What are access specifiers in java ?
Why put method is used?
Difference between string, stringbuffer and stringbuilder?
Explain restrictions on using enum?
Why is flag used in java?
Explain the difference between abstract class and interface in java?
Mention a package that is used for linked list class in java.
What is the difference between compiler and jvm?