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 make main() thread as daemon?
What is the Difference between Final Class && Abstract Class?
Can you start a thread twice in Java?
Can we have any code between try and catch blocks?
Can we store variables in local blocks?
Explain how to force the garbage collection in java.
Can inner class final?
Does java have extension methods?
What is a method type?
What is a variable in java?
I have multiple constructors defined in a class. Is it possible to call a constructor from another constructor’s body?
What is supplier in java?
I want my class to be developed in such a way that no other class (even derived class) can create its objects. How can I do so?
Is overriding possible in java?
What are java methods?