Exception Handling in Java Mcqs
Our collections of Multiple choice questions and answers focuses on study of Exception Handling in Java. These questions are chosen from a collection of most authoritative and best reference books on Java. Our aim is to prepare an individual for competitive exams like NTS, GAT, ECAT, University and College entrance exams and various tests and job interviews. One should practice our Mcqs to assimilate Exception Handling in Java topic comprehensively.
Java Programming Mcqs
- Data Types Variables and Arrays Mcqs
- Exception Handling in Java Mcqs
- Interfaces and Packages Mcqs
- Java Classes and Methods Mcqs
- Java Event Handling Mcqs
- Java Inheritance Mcqs
- Java IO and Applets Mcqs
- java lang and java io Mcqs
- Java Language Fundamentals Mcqs
- Java Operators and Control Statements Mcqs
- java utilities Mcqs
- Miscellaneous Topics in Java Mcqs
- Multithreading in Java Mcqs
- Serialization and Networking Mcqs
- Session Management and JSP and Servlet Mcqs
- String Handling
Computer MCQS
Sciences MCQS
2.
Which part of code gets executed whether exception is caught or not?
Finally
Try
Catch
Throw
3.
Which of the following should be true of the object thrown by a thrown statement?
Should be assignable to String type
Should be assignable to Exception type
Should be assignable to Throwable type
Should be assignable to Error type
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
4.
Which of these clause will be executed even if no exceptions are found?
Throws
Finally
Throw
Catch
5.
What is the output of this program?<br/>Note : Execution command line : $ java exception_handling
class exception_handling
{
public static void main(String args[])
{
try
{
int a = args.length;
int b = 10 / a;
System.out.print(a);
}
catch (ArithmeticException e)
{
System.out.println("1");
}
}
}
class exception_handling
{
public static void main(String args[])
{
try
{
int a = args.length;
int b = 10 / a;
System.out.print(a);
}
catch (ArithmeticException e)
{
System.out.println("1");
}
}
}
0
1
Compilation Error
Runtime Error
6.
What is the output of this program?
class exception_handling
{
public static void main(String args[])
{
try
{
throw new NullPointerException ("Hello");
}
catch(ArithmeticException e)
{
System.out.print("B");
}
}
}
class exception_handling
{
public static void main(String args[])
{
try
{
throw new NullPointerException ("Hello");
}
catch(ArithmeticException e)
{
System.out.print("B");
}
}
}
A
B
Compilation Error
Runtime Error
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
7.
Which of these keywords are used for the block to be examined for exceptions?
Try
Catch
Throw
Check
8.
Which of these statements is incorrect?
Try block need not to be followed by catch block
Try block can be followed by finally block instead of catch block
Try can be followed by both catch and finally block
Try need not to be followed by anything
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
9.
What is the output of this program?
class Output
{
public static void main(String args[])
{
try
{
int a = 0;
int b = 5;
int c = b / a;
System.out.print("Hello");
}
catch(Exception e)
{
System.out.print("World");
}
}
}
class Output
{
public static void main(String args[])
{
try
{
int a = 0;
int b = 5;
int c = b / a;
System.out.print("Hello");
}
catch(Exception e)
{
System.out.print("World");
}
}
}
Hello
World
HelloWOrld
Compilation Error
10.
What is the output of this program?
class Output
{
public static void main(String args[])
{
try
{
int a = 0;
int b = 5;
int c = a / b;
System.out.print("Hello");
}
catch(Exception e)
{
System.out.print("World");
}
}
}
class Output
{
public static void main(String args[])
{
try
{
int a = 0;
int b = 5;
int c = a / b;
System.out.print("Hello");
}
catch(Exception e)
{
System.out.print("World");
}
}
}
Hello
World
HelloWOrld
Compilation Error
11.
Which of these classes is used to define exceptions?
Exception
Throwable
Abstract
System
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
12.
Which of these methods return description of an exception?
GetException()
GetMessage()
ObtainDescription()
ObtainException()
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
13.
Which of these methods is used to print stack trace?
ObtainStackTrace()
PrintStackTrace()
GetStackTrace()
DisplayStackTrace()
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
14.
Which of these methods return localized description of an exception?
GetLocalizedMessage()
GetMessage()
ObtainLocalizedMessage()
PrintLocalizedMessage()
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
15.
Which of these classes is super class of Exception class?
Throwable
System
RunTime
Class
Answer & Solution
No Solution for this Answer..! Report or Discus this Question