
java quiz on exception handling

Quiz
•
Computers
•
University
•
Hard
Anupam Yadav
Used 268+ times
FREE Resource
20 questions
Show all answers
1.
MULTIPLE SELECT QUESTION
30 sec • 1 pt
Which of these keywords is not a part of exception handling?
try
finally
thrown
catch
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
public class Foo
{
public static void main(String[] args)
{
try
{
return;
}
finally
{
System.out.println( "Finally" );
}
}
}
Finally
Compilation fails.
The code runs with no output
An exception is thrown at runtime.
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What will be the output of the program?
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");
finished
runtime error.
Compilation fails
Exception.
4.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
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()
{
throw new Error(); /* Line 22 */
}
}
ABCD
Compilation fails.
C is printed before exiting with an error message.
BC is printed before exiting with an error message
5.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
public class X
{
public static void main(String [] args)
{
try
{
badMethod();
System.out.print("A");
}
catch (RuntimeException ex) /* Line 10 */
{
System.out.print("B");
}
catch (Exception ex1)
{
System.out.print("C");
}
finally
{
System.out.print("D");
}
System.out.print("E");
}
public static void badMethod()
{
throw new RuntimeException();
}
}
BD
BDE
BD
DE
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
java.lang.NullPointerException is a
Error
runtime exception
Compile time exception
None
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
FileNotFoundException
Is a subclass/extends IOException
Is a Compile time exception
Found in java.io package
All
Create a free account and access millions of resources
Similar Resources on Wayground
25 questions
Java Review

Quiz
•
9th Grade - University
15 questions
Java Quiz based on array

Quiz
•
University
21 questions
quiz 2nd/3rd year

Quiz
•
University
23 questions
Java Array

Quiz
•
University
20 questions
UTS Teori PJR 2024

Quiz
•
University
25 questions
Java Quiz

Quiz
•
University
20 questions
Java, part I

Quiz
•
11th Grade - University
16 questions
Arithmetic Types Declare Initialize Relation Logical Ops

Quiz
•
9th Grade - University
Popular Resources on Wayground
50 questions
Trivia 7/25

Quiz
•
12th Grade
11 questions
Standard Response Protocol

Quiz
•
6th - 8th Grade
11 questions
Negative Exponents

Quiz
•
7th - 8th Grade
12 questions
Exponent Expressions

Quiz
•
6th Grade
4 questions
Exit Ticket 7/29

Quiz
•
8th Grade
20 questions
Subject-Verb Agreement

Quiz
•
9th Grade
20 questions
One Step Equations All Operations

Quiz
•
6th - 7th Grade
18 questions
"A Quilt of a Country"

Quiz
•
9th Grade