Advanced_enterprise_java Flashcards

1
Q

What are the possible uses of reflection?

A
  • Reflection in Java allows you to inspect or manipulate classes, methods, fields, and other components of your program during runtime. It can be used for creating dynamic proxies, implementing dependency injection containers like Spring, and performing various forms of introspection.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Spring?

A
  • Spring is a popular open-source framework for building Java applications. It provides comprehensive infrastructure support for developing enterprise-grade applications. Spring offers features such as dependency injection, aspect-oriented programming, data access, and more.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is Spring Boot?

A
  • Spring Boot is an extension of the Spring framework that simplifies the process of building production-ready applications. It includes various conventions and defaults to minimize configuration and provide a seamless development experience.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the major difference between the Standard edition (JSE) and Enterprise edition (JEE)? You can choose Spring (Spring Boot) instead of JavaEE. Focus on comparing them.

A
  • Both Spring and Java EE (now Jakarta EE) are used for building enterprise applications, but Spring provides a more lightweight and flexible approach. Spring allows you to choose the components you need, while Java EE provides a more standardized set of features.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the advantages of the Spring Framework? Focus on the Core part.

A
  • Inversion of Control (IoC): Spring implements the IoC principle, which shifts the responsibility of object creation and management from the application code to the framework.
  • Dependency Injection (DI): DI is a key component of IoC, where Spring automatically injects dependencies into components, reducing the need for explicit instantiation and manual configuration.
  • Declarative Transaction Management: Simplifies managing database transactions.
  • Unified Exception Handling: Spring offers a consistent way to handle exceptions by using a central exception hierarchy.
  • Testing Support: Spring’s IoC and DI principles make it easier to write unit tests with mock objects and stubs, ensuring that individual components can be tested in isolation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a servlet? What is the purpose of DispatcherServlet in Spring?

A
  • A servlet is a Java class that handles requests and generates responses within a web server environment. It’s a fundamental component for building web applications in Java.
  • The DispatcherServlet is the front controller in the Spring web MVC framework. It receives incoming requests, processes them, and delegates to appropriate handlers for further processing. It plays a central role in request processing and helps manage the entire request-response lifecycle.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

When do you use RestControllers, when just simple Controllers?

A
  • RestControllers: Used to handle RESTful web service requests. They return data in various formats (JSON, XML) rather than rendering views.
  • Controllers: Used for traditional web applications. They handle requests, process data, and return views (HTML pages).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is Spring Application Context?

A
  • The Spring Application Context is a container that holds the configuration and components of a Spring-based application. It manages the lifecycle of beans, handles dependency injection, and provides access to application-wide services.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the main ways to define a bean in the Application Context?

A
  • XML Configuration: Using XML files to define beans and their relationships.
  • Java Configuration: Using Java classes annotated with @Configuration to define beans.
  • Component Scanning: Automatically discovering and registering beans using annotations like @Component.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Difference between .jar and .war files.

A
  • JAR (Java Archive): A package format for Java libraries or standalone applications.
  • WAR (Web Application Archive): A package format for Java web applications. It includes web resources, classes, and configuration files.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are the major differences between Maven, Ant and Gradle?

A
  • Maven: Focuses on project lifecycle management and dependency resolution using a declarative XML configuration (pom.xml).
  • Ant: Uses imperative XML-based scripts for building and managing projects.
  • Gradle: Employs a Groovy-based DSL, offering flexibility, powerful dependency management, and build customization.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is Maven used for?

A
  • Maven is a build automation and project management tool. It simplifies the building, testing, and deployment of projects by providing a consistent structure and centralized dependency management.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does a pom.xml file contains in Maven?

A
  • The pom.xml file in Maven contains project information, configuration settings, and dependencies. It defines project metadata, plugins, build instructions, and external dependencies.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is an ORM? What are the benefits, when to use?

A
  • ORM is a technique used to map objects in an application to database tables. It simplifies database interaction by allowing developers to work with objects and their relationships, rather than writing raw SQL queries.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the difference between JDBC and JPA? Which are the advantages and disadvantages of each? Give a general overview.

A
  • JDBC: Provides a low-level API for interacting with databases through SQL queries.
  • JPA (Java Persistence API): A higher-level specification that defines a set of interfaces and annotations for ORM frameworks like Hibernate.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is Hibernate? What are the advantages, limitations?

A
  • Hibernate is a popular ORM framework for Java applications. It provides an abstraction layer over relational databases, allowing developers to work with Java objects instead of SQL
17
Q

Name 3 different annotations used in JPA, what can they do for you?

A
  • @Entity: Marks a class as a persistent entity.
  • @Id: Specifies the primary key of an entity.
  • @ManyToOne, @OneToMany, @OneToOne: Define relationships between entities.
18
Q

What is object-relational impedance mismatch?

A
  • It refers to the differences between the object-oriented programming paradigm and the relational database model. ORM frameworks like Hibernate aim to bridge this gap.
19
Q

What is a JpaRepository? What are the 2 main methods to define queries in them?

A

JpaRepository is a Spring Data interface that extends the CrudRepository. It provides CRUD (Create, Read, Update, Delete) operations for JPA entities along with additional methods for querying.

20
Q

Why is the Set preferred over List when we want to store OneToMany relations?

A
  • A Set is preferred over a List for OneToMany relationships to ensure that each child entity is unique in the collection. In a List, the same child entity could be added multiple times.
21
Q

What kind of inheritance strategies are available? Which annotations are used to solve this?

A
  • @Inheritance: Annotation used to specify inheritance strategy.
  • Strategies: SINGLE_TABLE, TABLE_PER_CLASS, JOINED.