Java
T
point
Home
Python
Java
JavaScript
HTML
SQL
PHP
C#
C++
DS
Aptitude
Reasoning
Selenium
DBMS
C
Android
Interview Q
Content Menu ▼
1
2
3
4
5
6
7
8
9
10
Question 1
:
We know that the method printStackTrace of an exception prints the stack of methods that have been call when that exception has ocurred. What stack trace will be printed after calling method1?
public void method1() throws Exception {
method2();
}
public void method2() throws Exception {
throw method3();
}
public Exception method3() {
return new Exception();
}
1.
Exception in thread "main" java.lang.Exception
at mypackage.MyClass.method3(MyClass.java:30)
2.
Exception in thread "main" java.lang.Exception
at mypackage.MyClass.method2(MyClass.java:20)
3.
Exception in thread "main" java.lang.Exception
at mypackage.MyClass.method1(MyClass.java:10)