Advanced_enterprise_java Flashcards
What are the possible uses of reflection?
- 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.
What is Spring?
- 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.
What is Spring Boot?
- 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.
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.
- 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.
What are the advantages of the Spring Framework? Focus on the Core part.
- 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
What is a servlet? What is the purpose of DispatcherServlet in Spring?
- 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.
When do you use RestControllers, when just simple Controllers?
- 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).
What is Spring Application Context?
- 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.
What are the main ways to define a bean in the Application Context?
- 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.
Difference between .jar and .war files.
- 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.
What are the major differences between Maven, Ant and Gradle?
- 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.
What is Maven used for?
- 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.
What does a pom.xml file contains in Maven?
- The
pom.xml
file in Maven contains project information, configuration settings, and dependencies. It defines project metadata, plugins, build instructions, and external dependencies.
What is an ORM? What are the benefits, when to use?
- 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.
What is the difference between JDBC and JPA? Which are the advantages and disadvantages of each? Give a general overview.
- 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.