NPTEL Programming in Java Assignment 5 Answers (Week 5)
Q1. Which of the following is not true about throw
a. Throw is used inside a function
b. Throw can be used to declare multiple exception
c. Throw is followed by an instance
d. Throw is a keyword
Answer: b. Throw can be used to declare multiple exception
Q2. Which of the following is not true about custom exception in java?
a. class Exception extends Exp {
public Exception () {super ();}
public Exception (String s) {super(s);}
}
b. class Exception extends Exp{
Exception(String s){
super(s);
}
}
c. public class Exception extends Exp {
public Exception(String s) {
super(s);
}
}
d. class Exception extends Exp {
public Exception () {super ();}
Answer: d. class Exception extends Exp {
public Exception () {super ();}
Q3. Which of the following is not a property of tagged interface?
a. Serializable
b. Cloneable
c. Remote
d. Cascading
Answer: d. Cascading
Q4. Which of the following is not an exception in Java?
a. SQLException
b. ArrayIndexOutOfBoundException
c. OutOfMemoryError
d. StackOverflow
Answer: d. StackOverflow
Q5. Which of the following is type of Java Exception?
a. unchecked
b. checked
c. a & b
d. error
Answer: c. a & b
Q6. Which of the following keywords is not a part of exception handling?
a. try
b. throws
c. throw
d. thrown
Answer: d. thrown
Q7. Which of the option is correct regarding multiple catch blocks?
a. The subclass exception cannot be caught at first
b. The superclass exception cannot be caught at first
c. The subclass exception must be caught at last
d. The superclass exception must be caught at first
Answer: b. The superclass exception cannot be caught at first
Q8. When an array element is accessed beyond the array size, then which exception occurs
a. ArrayElementOutOfBound
b. ArrayIndexOutOfBound
c. ArraySizeOutOfBound
d. None of the above
Answer: d. None of the above
Q9. What is the output of this program?
class ExceptionHandling{
public static void main(String args[]) {
try{
int num1, num2;
num1 = 5;
num2 = num1/0;
System.out.print("A");
}
catch(ArithmeticException e) {
System.out.print("0");
}
finally {
System.out.print("B");
}
}
}
a. 0
b. A
c. 0
d. 0B
Answer: d. 0B
Q10. When does an exception occur?
a. During the time of compilation of a Java program
b. During the time of execution of a Java program
c. Anytime, that is, during compilation and execution of a program
d. At the end of execution of a Java program, if there is an exception
Answer: b. During the time of execution of a Java program
Disclaimer: These answers are provided only for the purpose to help students to take references. This website does not claim any surety of 100% correct answers. So, this website urges you to complete your assignment yourself.
Also Available:
NPTEL Programming in Java Assignment 4 Answers
NPTEL Cloud Computing Week 5 Assignment Answers
NPTEL An Introduction to Programming in C++ Assignment 5 Solutions