0% found this document useful (0 votes)
6 views2 pages

TA Filter

Multiple choice Java question and answers for freshers
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

TA Filter

Multiple choice Java question and answers for freshers
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

1. 6. How do you iterate over a Map in Java?

Answer:There are several ways to iterate over a Map in Java:

a) Using keySet()
b) Using entrySet()
c) Using Java 8 streams

2. 1. What are the main interfaces in the Java Collections Framework?

Answer: The main interfaces in the Java Collections Framework are:

List: Ordered collection with duplicates allowed.


Set: Unordered collection with no duplicates allowed.
Map: Key-value pairs where keys are unique.

3. Explain the difference between ArrayList and LinkedList. When would you use one
over the other?

Answer: ArrayList is backed by an array and provides fast access to elements by


index, while LinkedList is implemented as a doubly-linked list and is better for
frequent insertions and removals in the middle. Use ArrayList when you need fast
random access, and LinkedList when you need efficient insertions and deletions.

4. Question: Explain the purpose of the Iterator interface.

Answer: The Iterator interface is used to iterate through the elements of a


collection. It provides methods like hasNext() and next() for sequential access to
the elements.

5. Question: What is the purpose of the Deque interface, and name some implementing
classes.

Answer: The Deque interface (double-ended queue) represents a queue where elements
can be added or removed from both ends. Implementing classes include ArrayDeque and
LinkedList.

6. Question: Explain the difference between INNER JOIN and LEFT JOIN.

Answer:
INNER JOIN: Returns only the rows where there is a match in both tables.
LEFT JOIN: Returns all rows from the left table and the matched rows from the right
table. If there is no match, NULL values are returned for columns from the right
table.

7. Write a query to get all the unique values of Job_Title from Employees table.
Answer: SELECT DISTINCT (Job_Title) FROM EMPLOYEES.

8. What is a composite key in RDBMS?


Answer:
In a relational database management system (RDBMS), a composite key is a key that
consists of two or more columns to uniquely identify a record within a table.

9. Question: How does Spring Boot simplify the development of microservices?

Answer: Spring Boot simplifies microservices development by providing embedded


servers, easy configuration management, and a set of dependencies for building
robust and scalable microservices. It also supports the development of RESTful APIs
and includes features like Spring Cloud for building distributed systems.
10. Why we use @ComponentScan annotation?
Answer: The @ComponentScan annotation in Spring is used to specify the base
packages for Spring to scan for components, such as beans, controllers, and other
Spring-managed classes. This annotation plays a crucial role in the auto-discovery
of Spring components, allowing the framework to identify and register them during
the application context initialization.

11. Why @Autowired annotation is used in Java SpringBoot?


Answer:
The @Autowired annotation is a key component of Dependency Injection in Spring
Boot. It can be used on a constructor, a setter method, or directly on a field to
indicate the dependency to be injected.

12. Why are profiles used in SpringBoot?


Answer:
Profiles in Spring Boot are used to define a set of configurations, beans, and
other application components that are specifically tailored for a certain
environment or use case. They provide a way to customize the behavior of a Spring
Boot application based on different conditions, such as development, testing,
production, or any other specific scenario. Profiles are helpful for managing
configuration differences and dependencies in various deployment environments.

You might also like