
Java Exception Handling Quiz
Quiz
•
Information Technology (IT)
•
University
•
Hard
Ashok Pate
Used 1+ times
FREE Resource
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()
Create a free account and access millions of resources
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?
Similar Resources on Wayground
15 questions
Microsoft Word 2019 Advanced – Unit 1 (Review of Basic Concepts)
Quiz
•
10th Grade - University
20 questions
BÀI KIỂM TRA 15 PHÚT - Môn Tin Học 10 - HK2-PYTHON
Quiz
•
10th Grade - University
20 questions
Microsoft Excel Review Part 2
Quiz
•
8th Grade - University
16 questions
Sistematizacija gradiva IX
Quiz
•
9th Grade - University
16 questions
Understanding Assembly Language , Algorithms ,pseudocode
Quiz
•
University
15 questions
CMDP2063 Unix and C Programming
Quiz
•
University
20 questions
DSA (QUIZ 6) Hashing, Graphs, Advanced Graph Algorithms, and DP
Quiz
•
University
15 questions
แข่งขันcodingม.ปลาย
Quiz
•
12th Grade - University
Popular Resources on Wayground
20 questions
Halloween Trivia
Quiz
•
6th - 8th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
15 questions
Order of Operations
Quiz
•
5th Grade
20 questions
Halloween
Quiz
•
5th Grade
16 questions
Halloween
Quiz
•
3rd Grade
12 questions
It's The Great Pumpkin Charlie Brown
Quiz
•
1st - 5th Grade
20 questions
Possessive Nouns
Quiz
•
5th Grade
10 questions
Halloween Traditions and Origins
Interactive video
•
5th - 10th Grade
Discover more resources for Information Technology (IT)
10 questions
Halloween Movies Trivia
Quiz
•
5th Grade - University
12 questions
Halloween
Quiz
•
3rd Grade - University
5 questions
Using Context Clues
Interactive video
•
4th Grade - University
20 questions
Definite and Indefinite Articles in Spanish (Avancemos)
Quiz
•
8th Grade - University
7 questions
Force and Motion
Interactive video
•
4th Grade - University
14 questions
Eat Healthy,Be Healty
Quiz
•
4th Grade - University
7 questions
History of Halloween: Pagan or Christian?
Interactive video
•
11th Grade - University
7 questions
Renewable and Nonrenewable Resources
Interactive video
•
4th Grade - University
