Java Exception Handling Quiz

Java Exception Handling Quiz

University

20 Qs

quiz-placeholder

Similar activities

Quiz FDA

Quiz FDA

University

20 Qs

Living in the IT Era: Knowledge Assessment

Living in the IT Era: Knowledge Assessment

University

16 Qs

S2 Microsoft Access Database Quiz

S2 Microsoft Access Database Quiz

10th Grade - University

15 Qs

KVN naik Quizz 1

KVN naik Quizz 1

University

20 Qs

ICC_Module_6

ICC_Module_6

University

20 Qs

5-sinf. Kompyuter va Internet Asoslari

5-sinf. Kompyuter va Internet Asoslari

5th Grade - University

15 Qs

Java Basics, operators and variables (CH/PT)

Java Basics, operators and variables (CH/PT)

University

16 Qs

6-sinfl. Ofis dasturlari va Scratch

6-sinfl. Ofis dasturlari va Scratch

6th Grade - University

15 Qs

Java Exception Handling Quiz

Java Exception Handling Quiz

Assessment

Quiz

Information Technology (IT)

University

Practice Problem

Hard

Created by

Ashok Pate

Used 1+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

20 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following Java code snippet? class method { 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 arr[] = new int[8]; arr[8] = 9; } } catch (ArrayIndexOutOfBoundsException e) { System.out.println("TypeA"); } catch (ArithmeticException e) { System.out.println("TypeB"); } } } }

Runtime Error

Compilation Error

TypeB

TypeA

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of this Java program? class exception_handling { static void throwexception() throws ArithmeticException { System.out.print("0"); throw new ArithmeticException ("Exception"); } public static void main(String args[]) { try { throwexception(); } catch (ArithmeticException e) { System.out.println("A"); } } }

None of these.

Exception

0A

0

A

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of these keywords is used to manually throw an exception?

catch

try

finally

throw

None of these.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of these operators is used to generate an instance of exception than can be thrown by using throw?

alloc

None of these.

thrown

new

malloc

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Select the best answer for the code given below? class Trouble { void rightHere() { throw new Exception(); } }

You cannot throw an instance of the Exception class.

The throw keyword is not used correctly.

The method rightHere() is not defined correctly.

None of these.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the below Java program? class Myexception extends Exception { int detail; Myexception(int a) { detail = a; } public String toString() { return "detail"; } } class method { 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"); } } }

Exception

Runtime Error

Compilation Error

None of these.

3

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of these methods return description of an exception?

obtainException()

obtainDescription()

getMessage()

None of these.

getException()

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?