Welcome to the Exception Handling in Java MCQs Page
Dive deep into the fascinating world of Exception Handling in Java with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Exception Handling in Java, a crucial aspect of Java Programming. In this section, you will encounter a diverse range of MCQs that cover various aspects of Exception Handling in Java, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within Java Programming.
Check out the MCQs below to embark on an enriching journey through Exception Handling in Java. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of Java Programming.
Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Exception Handling in Java. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!
Exception Handling in Java MCQs | Page 6 of 9
Explore more Topics under Java Programming
class exception_handling
{
public static void main(String args[])
{
try
{
throw new NullPointerException ("Hello");
System.out.print("A");
}
catch(ArithmeticException e)
{
System.out.print("B");
}
}
}
class Myexception extends Exception
{
int detail;
Myexception(int a)
{
detail = a;
}
public String toString()
{
return "detail";
}
}
class Output
{
static void compute (int a) throws Myexception
{
throw new Myexception(a);
}
public static void main(String args[])
{
try
{
compute(3);
}
catch(Exception e)
{
System.out.print("Exception");
}
}
}
Note : Execution command line : $ java exception_handling one
class exception_handling
{
public static void main(String args[])
{
try
{
int a = args.length;
int b = 10 / a;
System.out.print(a);
try
{
if (a == 1)
a = a / a - a;
if (a == 2)
{
int c = {1};
c[8] = 9;
}
}
catch (ArrayIndexOutOfBoundException e)
{
System.out.println("TypeA");
}
catch (ArithmeticException e)
{
System.out.println("TypeB");
}
}
}
}
public class Test
{
public static void aMethod() throws Exception
{
try /* Line 5 */
{
throw new Exception(); /* Line 7 */
}
finally /* Line 9 */
{
System.out.print("finally "); /* Line 11 */
}
}
public static void main(String args[])
{
try
{
aMethod();
}
catch (Exception e) /* Line 20 */
{
System.out.print("exception ");
}
System.out.print("finished"); /* Line 24 */
}
}
public class X
{
public static void main(String [] args)
{
try
{
badMethod();
System.out.print("A");
}
catch (Exception ex)
{
System.out.print("B");
}
finally
{
System.out.print("C");
}
System.out.print("D");
}
public static void badMethod() {}
}
public class X
{
public static void main(String [] args)
{
try
{
badMethod(); /* Line 7 */
System.out.print("A");
}
catch (Exception ex) /* Line 10 */
{
System.out.print("B"); /* Line 12 */
}
finally /* Line 14 */
{
System.out.print("C"); /* Line 16 */
}
System.out.print("D"); /* Line 18 */
}
public static void badMethod()
{
throw new RuntimeException();
}
}
public class MyProgram
{
public static void main(String args[])
{
try
{
System.out.print("Hello world ");
}
finally
{
System.out.println("Finally executing ");
}
}
}
class Exc0 extends Exception { }
class Exc1 extends Exc0 { } /* Line 2 */
public class Test
{
public static void main(String args[])
{
try
{
throw new Exc1(); /* Line 9 */
}
catch (Exc0 e0) /* Line 11 */
{
System.out.println("Ex0 caught");
}
catch (Exception e)
{
System.out.println("exception caught");
}
}
}
public class Foo
{
public static void main(String[] args)
{
try
{
return;
}
finally
{
System.out.println( "Finally" );
}
}
}
try
{
int x = 0;
int y = 5 / x;
}
catch (Exception e)
{
System.out.println("Exception");
}
catch (ArithmeticException ae)
{
System.out.println(" Arithmetic Exception");
}
System.out.println("finished");
Suggested Topics
Are you eager to expand your knowledge beyond Java Programming? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!