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
Explain about join() method?
What is the difference between the file and randomaccessfile classes?
State one difference between a template class and class template.
Which are different kinds of source code?
What is Recursion Function?
Why singleton class is used in java?
Is an object null?
What is the significance of java packages?
What is the base class of all classes?
Difference between throw and throws?
Can you give names of Container classes?
What is ternary operator?
What are the two types of streams offered by java 8?
Explain the protected field modifier?
Convert a BST into a DLL and DLL to BST in place.