• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 1 out of 3 pages
Exam (elaborations)

Java spring boot interview Questions And Answers Rated 100%!!!

Document preview thumbnail
Preview 1 out of 3 pages

What is implementation and interface inheritance? - ANS check chatgpt What type of exception is a null pointer exception in Java? - ANS Null pointer exception is a type of runtime exception in Java. What are runtime exceptions in Java? - ANS exception that occur at runtime due to circumstances beyond control of programmer such as accessing null object reference, dividing by zero or trying to access an array element with an index that is out of bounds. Because runtime exceptions are unchecked exceptions, they do not need to be explicitly declared in the method signature or handled by the calling code. However you should check for null references using if (referenceVariable != null) before accessing them What are unchecked exceptions in Java? - ANS Unchecked exceptions are exceptions that are not checked at compile-time. This means the compiler does not require methods to declare them in their throws clause and it does not force you to handle them with try-catch blocks. Unchecked exceptions are derived from the 'RuntimeException' class which in turn is a subclass of Exception. Common unchecked exceptions: NullPointerException. Even though it is not thrown, you can still gracefully handle it in catch block. Unchecked exceptions, are typically thrown automatically by the JVM when a condition occurs such as dividing by zero. What is difference between Hibernate and JPA - ANS both manage persistence context and entity state but Hibernate is part of JPA implementation. Explain the difference between Session and QueryDSL - ANS Session is more low level and verbose compared to QueryDSL. What are some alternatives to using Session in Hibernate? - ANS Alternative provide higher-level abstractions: 1. Spring Data JPA 2. JPA EntityManager 3. Spring JdbcTemplate 4. Spring Data Jdbc 5. MyBatis 6. Spring Data Rest What is a Session in Hibernate? - ANS An interface to manage database operations and persistence contexts. Represents a single unit of work with database. Create, Read and Delete persistent objects, as well as manage transactions. What is difference between Session and EntityManager? - ANS EntityManager are higher level abstraction to Session. What is a database sequence? - ANS can be used to automatically generate primary key values What does the @Version annotation do in Hibernate? - ANS implements optimistic locking, which prevents concurrent updates from overwriting each other. What this means is if you have two transactions that want to update the same employee at the same time, it will not allow this to happen by throwing OptimisticLockException if one transaction already updated the version. Optimistic locking is a technique where instead of locking a database record during read or write operations, the app assumes that conflicts are unlikely to occur. When updates are made to a record, the application compares the version number of the record in the database with the version number of the record that the application has fetched. If they match, the application proceeds with the update and the version number is incremented in the database. If they do not match, it indicates that another transaction has modified the record since it was fetched and the application can handle the conflict accordingly.

Content preview

Spring Cert 2024 | Chapter 4 | Data JPA
Exam Questions And Answers


What is a Spring Data Repository interface? - ANS Aims to significantly reduce the amount
of boilerplate code required to implement data access layers for various persistence stores.

How do you define a Spring Data Repository interface? [2] Why is it an interface not a class? -
ANS a) Define Entity Class
b) Create an Interface (@Repository)
==> Should extend 1/4 Repository types
==> Should be parametrized w/ Entity type

public interface UserRepo extends JpaRepository<User, Long>

What is the naming convention for finder methods in a Spring Data Repository interface [4]? -
ANS 1) Verb [1/6] - {get, read, find, query, stream, count}

2) Limiter (Optional)

3) Subject (Optional)

4) Predicate [2] - consists of...
==> a) Property (required)
==> b) Comparison (optional, default is "equals")

[JAY] Regarding Spring Data Repository Interface methods' naming conventions, what parts are
optional [2]?

What part of the Predicate is optional? What does it default to? - ANS 1) Limiter - "first",
"top", etc.
2) Subject - Since Repo-Type is already parameterized w/ correct type

Predicate - Comparison is optional (defaults to "equals")

How are Spring Data repositories implemented by Spring at runtime? - ANS JDK Dynamic
Proxy - Intercepts all calls to repository
==> Routes calls to default repository impl (SimpleJpaRepository)

Document information

Uploaded on
November 15, 2024
Number of pages
3
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$10.79

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
DocLaura
4.2
(44)
Sold
161
Followers
38
Items
6357
Last sold
1 month ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions