Submitted by c-admin on Wed, 06/05/2019 - 05:54
What will be the output when the following program is run?
package exceptions;
public class TestClass{
public static void main(String[] args) {
try{
hello(); }
catch(MyException me){
System.out.println(me); } }
static void hello() throws MyException{
int[] dear = new int[7];
dear[0] = 747;
foo(); }
static void foo() throws MyException{
throw new MyException("Exception from foo"); } }
class MyException extends Exception {
public MyException(String msg){
super(msg); }
}
(Assume that line numbers printed in the messages given below are correct)
Select 1 option
A. Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 10
at exceptions.TestClass.doTest(TestClass.java:24)
at exceptions.TestClass.main(TestClass.java:14)
B. Error in thread "main" java.lang.ArrayIndexOutOfBoundsException
C. exceptions.MyException: Exception from foo
D. exceptions.MyException: Exception from foo
at exceptions.TestClass.foo(TestClass.java:29)
at exceptions.TestClass.hello(TestClass.java:25)
at exceptions.TestClass.main(TestClass.java:14)
Submitted by c-admin on Wed, 06/05/2019 - 05:50
Identify the Exceptions that will be received when the code snippets on the left hand side are executed.
Submitted by c-admin on Wed, 06/05/2019 - 05:37
Which of the following are standard Java exception classes?
Select 2 options
A. FileNotFoundException
B. InputException
C. CPUError
D. MemoryException
E. SecurityException
Submitted by c-admin on Wed, 06/05/2019 - 05:36
What will the following code print when run?
public class Test{
static String j = "";
public static void method( int i){
try{ if(i == 2){
throw new Exception(); }
j += "1"; }
catch (Exception e){
j += "2";
return; }
finally{
j += "3"; }
j += "4"; }
public static void main(String args[]){
method(1);
method(2);
System.out.println(j); } }
Select 1 option
A. 13432
B. 13423
C. 14324
D. 12434
E. 12342
Submitted by c-admin on Wed, 06/05/2019 - 05:27
Identify the Exceptions that SHOULD be thrown in the situations shown below.
Pages