Unit4 - Subjective Questions

CSE310 • Practice Questions with Detailed Answers

1

Differentiate between a Static Nested Class and a Non-Static Nested Class (Inner Class) in Java.

2

Explain the concept of Anonymous Inner Classes in Java. How are they useful for event handling or interface implementation?

3

Define a Functional Interface in Java. How does the @FunctionalInterface annotation work, and what is its relationship with Lambda expressions?

4

Describe the syntax of Lambda Expressions in Java. Provide examples for expressions with no parameters, single parameter, and multiple parameters.

5

Discuss the Exception Hierarchy in Java. Explain the roles of Throwable, Error, Exception, and RuntimeException.

6

Explain the keywords try, catch, and finally with a code example demonstrating the flow of execution.

7

Distinguish between throw and throws keywords in Java.

8

What is the Try-with-Resources statement in Java? How does it help in resource management compared to the traditional try-finally block?

9

Explain the concept of Exception Propagation in Java.

10

How can you handle multiple exceptions in a single catch block? Explain the Multi-catch feature introduced in Java 7.

11

Describe the process of creating a Custom Exception (User-defined Exception) in Java. Provide a code example.

12

What are Assertions in Java? Explain their syntax and how to enable them.

13

Discuss the Java 8 Date/Time API utility classes. How do LocalDate, LocalTime, and LocalDateTime differ from the old Date class?

14

What is a Local Inner Class? What are the restrictions on accessing local variables within a local inner class?

15

Explain the difference between Checked and Unchecked exceptions with examples.

16

Analyze the rules for Exception Handling with Method Overriding. What happens when a subclass overrides a method that throws an exception?

17

Explain the purpose of the Period and Duration classes in the Java Date/Time API.

18

Compare Lambda Expressions with Anonymous Inner Classes. When should you use one over the other?

19

Write a Java program fragment to demonstrate how to handle a NullPointerException and an ArrayIndexOutOfBoundsException.

20

What are the advantages of using Nested Classes in Java?