Predict the output of following Java program class Main { public static void mai
ID: 3570878 • Letter: P
Question
Predict the output of following Java program
class Main {
public static void main(String args[]) {
try {
throw 10;
}
catch(int e) {
System.out.println("Got the Exception " + e);
}
}
}
Got the Exception 10
Got the Exception 0
Compile Error
Suppose A is an inner class in Test. A is compiled into a file named ________.
A.class
Test$A.class
A$Test.class
Test&A.class
________ are checked exceptions.
RuntimeException
Exception
Throwable
IOException
A ________ method does not return a value.
void
non-void
Will the following code have a compile error?
ArrayList<String> list = new ArrayList<String>();
list.add(3);
Yes
No
Analyze the following code:
The program displays 0 1 2 3 4.
The program displays 0 1 2 3 4 and then raises a runtime exception.
The program displays 0 1 2 3 4 5.
The program displays 0 1 2 3 4 5 and then raises a runtime exception.
class Main {
public static void main(String args[]) {
try {
throw 10;
}
catch(int e) {
System.out.println("Got the Exception " + e);
}
}
}
Got the Exception 10
Got the Exception 0
Compile Error
Explanation / Answer
1. Compile error
2.Test$A.class
3.IOException
4.void
5.No
6.The program displays 0 1 2 3 4.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.