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
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 list = new ArrayList(); 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. |
public class Test{ public static void } } main(String[] args) { } int[] x = {0, 1, 2, 3, 4, 5); xMethod (x, 5); public static void xMethod (int[] x, int length) { for (int i = 0; i
Step by Step Solution
3.37 Rating (153 Votes )
There are 3 Steps involved in it
Step: 1
1 c Compile Error In Java it is not possible to throw a primitive data type such as an int or a float Only objects can be thrown in Java Therefore the line throw 10 will result in a compile error To t...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started