No student devices needed. Know more
15 questions
What is the advantage of Exception Handling
To avoid abnormal termination of a program
To find out errors
To Debug program
None of these
What is the parent class of All Exceptions in JAVA
Throw
Exception
Error
Bug
Which of the following key word is optional in Exception handling program
try
catch
finally
throw
try block may or may not contains catch blocks
True
False
What is the purpose of 'throw' keyword
To Raise an exception explicityly
To Raise an exception implicityly
To create user defined exceptions
To create custom exceptions
Which of the following exceptions class belongs to Checked Exception
ArithmeticException
ClassNotFoundExceptions
ClassCastException
ArrayIndexOutOfBoundsException
class IT
{
static public void main(String...args)
{
int k=Integer.parseInt(args[0]);
System.out.println(k);
}
}
if args[0]="gec" then what type of exception is thrown by the above program.
NumberFormatException
NullPointerException
ArrayIndexOutOfBoundsException
InvalidStringException
What are immediate child classes of Throwable
Error
Exception
CheckedException
UnCheckedException
class Add
{
static public void main(String...args)
{
try
{
int a=10,b=0;
System.out.println(a/b);
}
catch(ArithmeticException ex)
{
System.out.println("Error:");
}
}
}
Above program throws an exception at
Runtime
Compile time
either compile time or run time
None of these
What is an exception
Error occurred during the execution of a program
Bug occurred during the compile time of a program
Simply an Error
It is related to input values
How to create our own exception
using 'throw' keyword
using 'throws' keyword
using 'finally' keyword
using 'throwable' keyword
class IT
{
static public void main(String...args)
{
String s=null;
System.out.println("length is:"+s.length());
}
}
It throws NullPointerException
it throws IOException
It throws StringExeption
output is 0
Nested try and Multi-try both are same
It is True
It is False
A java program contains any number of try and catch blocks
True
False
Exception classes belongs to following package
import java.io.*
import java.lang.*
import java.util.*
import java.lang.Exception.*
Explore all questions with a free account