NPTEL Programming In Java Week 5 Assignment Answers 2025

NPTEL Programming In Java Week 5 Assignment Answers 2025

1. Which of the following statements) is/are true about finally in Java?
I. The finally block is executed regardless of whether an exception is thrown or not.
II. A finally block can exist without a catch block.
III. The finally block will not execute if System. exit () is called in the try block.
IV. A finally block can have a return statement, but it is not recommended to use.

a. I and III
b. II and III
c. I, lI and III
d. I, II, III and IV

Answer :- For Answers Click Here 

2.

Answer :- 

3.

Answer :- 

4. Which of the following is TRUE regarding abstract class and an interface in Java?

I. Abstract classes can contain constructors, but interfaces cannot.
II. Interfaces support multiple inheritance, but abstract classes do not.
III bstract classes can have both abstract and concrete methods, whereas interfaces only had
IV. abstract methods before Java 8.

a. I, Il and Ill
b. Il only
c. I and II only
d. Il and IlI only

Answer :- 

5. Which of the following is a checked exception in Java?

a. NullPointerException
b. ArrayIndexOutOfBoundsException
c. 10Exception
d. ArithmeticException

Answer :- 

6. Which keyword is NOT used by Java during exception handling?

a. try
b. catch
c. final
d. finally

Answer :- For Answers Click Here 

7. What is the purpose of the throws keyword in Java?

a. To declare exceptions that a method can throw
b. To throw an exception immediately
c. To catch an exception
d. It is not a keyword in Java

Answer :- 

8. Which of the following is TRUE about interfaces in Java?

a. Interfaces should always be defined as final
b. Interfaces can be instantiated directly.
c. Interfaces can extend multiple interfaces.
d. Interfaces cannot have any methods signatures

Answer :- 

9.

Answer :- 

10.

Answer :- For Answers Click Here 
Scroll to Top