BNYM QC Flashcards

1
Q
  1. What is the new feature in Java 11 that allows the type of lambda parameters to be inferred using the ‘var’ keyword?
A
  • “Local-Variable” Syntax
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
  1. What new String methods were introduced?
A
  • isBlank()
  • lines()
  • strip()
  • stripLeading()
  • stripTrailing()
  • repeat()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
  1. What Collection related method was introduced?
A
  • Collection.toArray(IntFunction)
  • It is a default method added to the Collection Interface
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
  1. What other notable Java 11 features have been added or changed?
A
  • New File Methods
  • Not Predicate Method
  • HTTPClient
  • Can directly run Java source files with “java” CLI tool
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
  1. What is Pattern Matching? Which version of Java introduced it?
A
  • Used to test if an object has a particular structure and if so, then that data is extracted from that object
  • Introduced in Java 14
    -Added support for switch expressions
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
  1. What improvements did Java 17 add to Garbage Collection?
A
  • Parallel GC is much faster
  • Improved heap allocation to the G1GC
  • Introduced ZGC, which provides low latency and minimal pauses
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
  1. What is the purpose of the Java Platform Module System (JPMS)?
A
  • To encapsulate Java code into modules, making it easy to maintain large scale Java applications.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
  1. What is a module in JPMS? How is it different from a regular Java package?
A
  • A module is a unit of code that contains Java packages and resources.
  • It’s different from a Java package because it provides stronger encapsulation, which means only the specified parts of a module are accessible, and the rest remain hidden.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
  1. What is a module descriptor in JPMS? What information does it contain?
A
  • A file that describes the content and dependencies of a module.
  • It contains information such as the module name, packages it exports which make it accessible to other modules, and other optional configurations.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
  1. What are the benefits of using JPMS in terms of security and performance?
A
  • Security, JPMS enforces strong encapsulation, which helps prevent unauthorized access to internal code.
  • Performance, JPMS allows Java runtime to analyze and optimize module dependencies, resulting in more efficient loading of code.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
  1. What is the debugger?
A
  • A tool used to identify and resolve issues or bugs in software code.
  • It allows us to step through code line by line, inspect variables, and observe the program’s behavior in order to understand and fix any problem.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
  1. What is a breakpoint?
A
  • An international stopping point at a specific line of code
  • By stopping the program’s execution the developer can inspect variables at the given point.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
  1. Step Into vs Step Over vs Step Return?
A
  • Step Into goes inside the methods used in the current line; else it proceeds to the next line.
  • Step Over operation process the current line and proceeds to the next line.
  • Step Return operation finishes the current method and takes us back to the calling method.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
  1. What is variable inspection?
A
  • Returns the value of any method that is called in the current context.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
  1. Difference between a Collection and a Stream? What are the benefits of Stream API?
A
  • Collection is a framework that provides architecture to store and manipulate a group of objects, providing many interfaces such as set, list, queue, dequeue and classes such as ArrayList, LinkedList and more.
  • Stream is a sequence of objects that support various methods which can be pipelined to produce the desired result.
  • Benefits: Streams do not change the original data structure, succinctly express sophisticated behavior.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
  1. What is an intermediate operation? Can you give any examples?
A
  • Lazily executed operation that returns a stream
  • Examples: Map, Filter, Sorted
17
Q
  1. What’s a terminal operation? Can you give any examples?
A
  • Mark the end of the stream and return the result
  • Examples: Collect, forEach, Reduce, findAny, Min
18
Q
  1. Difference between H2 and RDBMS?
A
  • H2 is a specific database management system known for its lightweight nature and in-memory capabilities. It is often used for smaller applications and testing scenarios.
  • RDBMS is a class of database management systems that follow the relational model and are used in a wide range of applications, from small-scale to enterprise-level systems.
19
Q
  1. What is a transaction?
A
  • A unit of work that consists of multiple database operations, grouped together to ensure ACID properties.
20
Q
  1. Purpose of XA (eXtended Architecture) in transaction management?
A
  • Coordinates the transactional behavior of resources, ensuring that either all the resources commit their changes or all the changes are rolled back in case of any failure.
21
Q
  1. What is two-phase commit protocol (in distrubuted transactions)?
A
  • Prepare phase: The transaction manager ask each RM to prepare for committing the transaction. The RM then performs its local transaction operation and prepares to commit or rollback.
  • Commit phase: The transaction manager sends a commit request to each RM if they all respond with a successful prepare status. If any RM encounters an error during the prepare phase, the transaction manager sends a rollback requests to all the RMs for them to rollback the changes made during the transaction.
22
Q
  1. What is the role of a JTA Transaction Manager in distributed transactions?
A
  • Java Transaction API Manager is responsible for coordinating and managing transactions across multiple resources (such as databases, messages queues, and other transactional resources) in a distributed environment. It ensures the ACID properties of transactions.
23
Q
  1. Global vs Local Transaction?
A
  • Global transactions involve multiple resources that participate in a single distributed transaction. Typically managed by a transaction manager using protocols like the Two-phase commit.
  • Local Transaction involves a single resource, typically managed by a resource manager.
24
Q
  1. What is sorting and Pagination?
A
  • Sorting: Arranging data in a specific order based on one or more criteria.
  • Pagination: Divides a large dataset or list of items into smaller, discrete pages or chunks. Improves performance by reducing the amount of data transferred and rendered at once.
25
Q
  1. Transaction Management?
A
  • The process of ensuring the reliable and consistent execution of transactions in a system; ensure ACID properties.
  • Involves Transaction manager, Resource manager, and Transaction context.
26
Q
  1. What is @Transactional?
A
  • Metadata that specifies the semantics of the transaction on a method, allowing us to make changes to the database and automatically rollback when there is an issue.
  • We can configure propagation type, isolation level, timeout, readonly, and rollback rules
27
Q
  1. What are the different Transaction propagation options? What do they do?
A
  • Propagation.REQUIRES:
  • If a transaction exists, the method participates in that transaction
  • If no transaction exists, a new transaction is created
  • Propagation.SUPPORTS:
  • Method supports a transaction if one exists
  • If no transaction exists, the method executes non-transactionally
  • Propagation.MANDATORY:
  • The method requires a transaction to be already active
  • If no transaction exists, an exception is thrown
  • Propagation.REQUIRES_NEW:
  • The method always starts a new transaction
  • If a transaction exists, it is suspended until the new transaction completes
  • Once the new transaction is complete, the suspended transaction resumes
  • Propagation.NOT_SUPPORTED:
  • The method executes non-transactionally
  • If a transaction exists, it is suspended until the new transaction completes
  • Once the new transaction is complete, the suspended transaction resumes
  • Propagation.NEVER:
  • The method executes non-transactionally
  • If a transaction exists, an exception is thrown
  • Propagation.NESTED:
  • The method executes within a nested transaction
  • If a transaction exists, a new nested transaction is started
  • If no transaction exists, a new transaction is started
28
Q
  1. What are the different isolation levels? What do they do?
A
  • Isolation.DEFAULT:
  • The actual isolation level will be determined by the database’s default behavior
  • Isolation.READ_UNCOMMITTED:
  • Allows dirty reads, non-repeatable reads, and phantom reads
  • Provides the lowest level of isolation
  • Isolation.READ-COMMITTED:
  • Does not allow dirty reads but allows non-repeatable reads and phantom reads
  • This is the default isolation level in many database systems
  • Isolation.REPEATABLE_READ:
  • Prevents dirty reads and non-repeatable reads but allows phantom reads
  • Guarantees a consistent snapshot of data throughout a transaction.
  • Isolation.SERIALIZABLE:
  • Provides the highest level of isolation
  • Prevents dirty reads, non-repeatable reads, and phantom reads by acquiring locks on accessed data
29
Q
  1. JPA vs SQL?
A
  • JPA is a Java specification that provides a standardized API for Object-Relational Mapping (ORM)
  • SQL is a programming language designed for working with relational databases
29
Q
  1. JPA vs SQL?
A
  • JPA is a Java specification that provides a standardized API for Object-Relational Mapping (ORM)
  • SQL is a programming language designed for working with relational databases
30
Q
  1. What are the core interfaces in Hibernate?
A
  • Session, SessionFactory, and Configuration Interface are mandatory
  • Transaction, Query, and Criteria Interface