JAVA Exceptions In which of the following package Exception class exist? java.io java.util java.file java.net java.lang java.io java.util java.file java.net java.lang ANSWER DOWNLOAD EXAMIANS APP
JAVA Exceptions public class Test{ public static void main(String args[]){ try{ int a = Integer.parseInt("four"); } }}Which exception could be handled by the catch block for above? IllegalStateException None of these ClassCastException NumberFormatException ArrayIndexOutOfBoundsException IllegalStateException None of these ClassCastException NumberFormatException ArrayIndexOutOfBoundsException ANSWER DOWNLOAD EXAMIANS APP
JAVA Exceptions What will be the output?class MyClass{ public String test(){ try{ System.out.print("One"); return ""; } finally{ System.out.print("Two"); } }}public class Test{ public static void main(String args[]){ MyClass m = new MyClass(); m.test(); }} None of these One One Two Compilation Error Two None of these One One Two Compilation Error Two ANSWER DOWNLOAD EXAMIANS APP
JAVA Exceptions Predict the output:public class Test{ public static void main(String args[]){ try{ String arr[] = new String[10]; arr = null; arr[0] = "one"; System.out.print(arr[0]); }catch(Exception ex){ System.out.print("exception"); }catch(NullPointerException nex){ System.out.print("null pointer exception"); } }} "one" is printed. "null pointer exception" is printed. None of these "exception" is printed. Compilation fails saying NullPointerException has already been caught. "one" is printed. "null pointer exception" is printed. None of these "exception" is printed. Compilation fails saying NullPointerException has already been caught. ANSWER DOWNLOAD EXAMIANS APP
JAVA Exceptions try{ File f = new File("a.txt");}catch(Exception e){}catch(IOException io){}Is this code create new file name a.txt ? true None of these false Compilation Error true None of these false Compilation Error ANSWER DOWNLOAD EXAMIANS APP
JAVA Exceptions Given the following piece of code:class SalaryCalculationException extends Exception{}class Person{ public void calculateSalary() throws SalaryCalculationException{ //... throw new SalaryCalculationException(); //... }}class Company{ public void paySalaries(){ new Person().calculateSalary(); }}Which of the following statements is correct?1. This code will compile without any problems.2. This code will compile if in method paySalaries() we return a boolean in stead of void.3. This code will compile if we add a try-catch block in paySalaries().4. This code will compile if we add throws SalaryCalculationException in the signature of method paySalaries(). 2 and 3 3 and 4 1 and 4 2 and 4 1 and 2 2 and 3 3 and 4 1 and 4 2 and 4 1 and 2 ANSWER DOWNLOAD EXAMIANS APP