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:
![public class Test{ public static void } } main(String[] args) { }](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2022/12/638a25bd48d03_013638a25bd0e4bd.jpg)
| 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
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... View full answer
Get step-by-step solutions from verified subject matter experts
