0% found this document useful (0 votes)
4 views

Advanced questions

The document provides an overview of various Java concepts including Local Time and Date API, Inner Classes, Method References, Lambda Expressions, JDBC, Servlets, and Stream API. Each section contains basic understanding, usage examples, and advanced topics with questions aimed at exploring the functionality and implementation of these concepts. It serves as a comprehensive guide for understanding and applying Java programming techniques.

Uploaded by

Sapna Madhavai
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Advanced questions

The document provides an overview of various Java concepts including Local Time and Date API, Inner Classes, Method References, Lambda Expressions, JDBC, Servlets, and Stream API. Each section contains basic understanding, usage examples, and advanced topics with questions aimed at exploring the functionality and implementation of these concepts. It serves as a comprehensive guide for understanding and applying Java programming techniques.

Uploaded by

Sapna Madhavai
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Local Time and Date API

1. Basic Understanding

o What is the difference between java.util.Date and the new java.time API introduced
in Java 8?

o How do you create the current date and time using the LocalDateTime class?

2. Usage Examples

o Write a program to calculate the difference between two dates using the java.time
package.

o How can you format a LocalDate or LocalDateTime to a custom string


representation?

3. Advanced

o How does the ZonedDateTime class handle time zones? Provide an example.

o Write a program to calculate the number of days between today and a user-defined
date.

Inner Classes

1. Types

o What are the different types of inner classes in Java?

o How is a static nested class different from a non-static nested class?

2. Practical Usage

o Provide an example of a method-local inner class and explain its scope.

o Demonstrate the use of an anonymous inner class in event handling.

3. Advanced

o How do you access a member variable of the enclosing class from a non-static inner
class?

o Can you create a constructor in an inner class? Explain with an example.

Method References

1. Introduction

o What are method references in Java, and how are they related to lambda
expressions?

o What are the types of method references in Java? Provide examples.


2. Examples

o Demonstrate the use of a method reference to call a static method.

o Provide an example of a method reference to call an instance method of a particular


object.

3. Advanced

o How can you use method references with streams? Provide an example.

o Explain the difference between ClassName::new and ClassName::methodName in


method references.

Lambda Expressions

1. Basic Understanding

o What is a lambda expression in Java, and how is it different from an anonymous


class?

o Can you provide a use case where a lambda expression simplifies code?

2. Syntax and Use Cases

o Write a lambda expression to sort a list of strings in reverse order.

o How do you use a lambda expression to iterate over a collection in Java?

3. Functional Interfaces

o What are functional interfaces in Java, and how are they related to lambda
expressions?

o Name some commonly used functional interfaces in Java. Can you demonstrate the
use of one with a lambda expression?

4. Limitations

o Are lambda expressions allowed to modify local variables? Why or why not?

o How can you handle checked exceptions in a lambda expression?

1. Basics

o What is a lambda expression, and when should you use it?

o How do lambda expressions improve the readability and conciseness of the code?

2. Examples

o Write a lambda expression to filter even numbers from a list.

o How can you use lambda expressions with functional interfaces?

3. Advanced
o Explain the concept of "effectively final" variables in the context of lambda
expressions.

JDBC

1. Basics

o Explain the steps involved in making a database connection using JDBC.

o What is the purpose of the DriverManager class in JDBC?

2. Queries

o How do you execute a SQL query in JDBC? Provide an example.

o What is the difference between Statement, PreparedStatement, and


CallableStatement? When would you use each?

3. Error Handling

o How can you handle SQL exceptions in JDBC effectively? What is the purpose of the
SQLException class?

4. Performance

o How can you improve the performance of JDBC queries?

o What is connection pooling in JDBC, and why is it important?

JDBC

5. Basics

o What are the main components of the JDBC architecture?

o How does PreparedStatement improve performance and security over Statement?

6. Examples

o Write a program to retrieve data from a database using JDBC.

o How can you handle SQL exceptions in JDBC effectively?

7. Advanced

o What is batch processing in JDBC, and how can it be implemented?

o Explain the concept of connection pooling and how it enhances performance in


JDBC.

8.
Servlets

1. Lifecycle

o Explain the lifecycle of a servlet.

o What are the different methods of the HttpServlet class, and when are they called?

2. Request and Response

o How can you handle GET and POST requests in a servlet?

o Explain the role of ServletRequest and ServletResponse interfaces.

3. Session Management

o How do servlets handle session management? Provide examples of session tracking


techniques.

o What is the difference between cookies and URL rewriting for session tracking?

4. Error Handling

o How do you handle exceptions in servlets? Provide an example of custom error


handling.

Servlets

1. Lifecycle

o Explain the lifecycle of a servlet.

o What is the difference between the init() and service() methods?

2. Request Handling

o How do you handle GET and POST requests in a servlet?

o What is the purpose of the HttpServletRequest and HttpServletResponse objects?

3. Advanced

o How do you handle session management in servlets? Compare cookies and URL
rewriting.

o Provide an example of a servlet that interacts with a database to perform CRUD


operations.

Stream API

1. Overview

o What is the Stream API in Java, and how does it differ from traditional loops?

o Explain the difference between a sequential stream and a parallel stream.


2. Operations

o What is the difference between intermediate and terminal operations in the Stream
API?

o Provide an example of filtering a list using the Stream API.

3. Examples

o Write a Stream API example to find the maximum number in a list of integers.

o How can you use the Stream API to group elements of a collection by a specific
property (e.g., group students by grade)?

4. Advanced

o How can you use the Stream API to process a large dataset in parallel?

o Explain the difference between map and flatMap in the Stream API.Stream API

1. Core Concepts

o What are intermediate and terminal operations in streams? Provide examples of


each.

o How do you differentiate between map and flatMap in the Stream API?

2. Examples

o Write a program to count the number of elements in a list that satisfy a given
predicate.

o How can you use the Stream API to merge two lists?

3. Advanced

o What are parallel streams, and when should you avoid using them?

o Provide an example of using the reduce() method in the Stream API to calculate a
result.

Let me know if you'd like detailed answers for these questions or if you'd like me to export this
content to a PDF!

You might also like