Java Programming

Java is a high-level, object-oriented programming language developed by Sun Microsystems in the mid-1990s. It adheres to the “Write Once, Run Anywhere” (WORA) principle, ensuring platform independence via the Java Virtual Machine (JVM).

Java is a widely used programming language for coding web applications. It has been a popular choice among developers for over two decades, with millions of Java applications in use today. Java is a multi-platform, object-oriented, and network-centric language that can be used as a platform in itself. It is a fast, secure, reliable programming language for coding everything from mobile apps and enterprise software to big data applications and server-side technologies.

Which annotation is used to mark a class as an entity listener in JPA?

Java MCQ: Which annotation is used to mark a class as an entity listener in JPA? a) @EntityListener b) @Entity c) @Listener d) @EntityListeners Answer: d) @EntityListeners Explanation: The @EntityListeners annotation in JPA is used to mark a class or method as an entity listener. Entity listeners are used to intercept entity lifecycle events such […]

Which annotation is used to mark a class as an entity listener in JPA? Read More »

Which annotation is used to mark an entity as read-only in Hibernate?

Java MCQ: Which annotation is used to mark an entity as read-only in Hibernate? a) @Immutable b) @Transient c) @ReadOnly d) @Entity Answer: a) @Immutable Explanation: The @Immutable annotation in Hibernate is used to mark an entity as read-only. When an entity is annotated with @Immutable, Hibernate will not allow any modifications to the entity’s

Which annotation is used to mark an entity as read-only in Hibernate? Read More »

What does the @Inheritance annotation in JPA specify?

Java MCQ: What does the @Inheritance annotation in JPA specify? a) It defines a column inheritance strategy b) It specifies the table inheritance strategy c) It marks an entity as abstract d) It defines a primary key generation strategy Answer: b) It specifies the table inheritance strategy Explanation: The @Inheritance annotation in JPA specifies the

What does the @Inheritance annotation in JPA specify? Read More »

Which JPA annotation is used to define a many-to-many relationship?

Java MCQ: Which JPA annotation is used to define a many-to-many relationship? a) @OneToMany b) @ManyToMany c) @OneToOne d) @ManyToOne Answer: b) @ManyToMany Explanation: The @ManyToMany annotation is used to define a many-to-many relationship in JPA. This type of relationship means that multiple instances of one entity can be associated with multiple instances of another

Which JPA annotation is used to define a many-to-many relationship? Read More »

Which annotation is used to define a one-to-one relationship in JPA?

Java MCQ: Which annotation is used to define a one-to-one relationship in JPA? a) @OneToOne b) @OneToMany c) @ManyToOne d) @ManyToMany Answer: a) @OneToOne Explanation: The @OneToOne annotation is used to define a one-to-one relationship in JPA. This type of relationship indicates that one instance of an entity is associated with exactly one instance of

Which annotation is used to define a one-to-one relationship in JPA? Read More »

Which JPA annotation is used to define a one-to-many relationship?

Java MCQ: Which JPA annotation is used to define a one-to-many relationship? a) @ManyToMany b) @OneToOne c) @OneToMany d) @ManyToOne Answer: c) @OneToMany Explanation: The @OneToMany annotation is used to define a one-to-many relationship in JPA. This type of relationship indicates that one instance of an entity is associated with many instances of another entity.

Which JPA annotation is used to define a one-to-many relationship? Read More »

Which annotation is used to define a many-to-one relationship in JPA?

Java MCQ: Which annotation is used to define a many-to-one relationship in JPA? a) @OneToMany b) @ManyToOne c) @OneToOne d) @ManyToMany Answer: b) @ManyToOne Explanation: The @ManyToOne annotation is used to define a many-to-one relationship in JPA. This type of relationship means that many instances of an entity can be associated with one instance of

Which annotation is used to define a many-to-one relationship in JPA? Read More »

Which annotation is used to automatically generate primary key values in JPA?

Java MCQ: Which annotation is used to automatically generate primary key values in JPA? a) @AutoKey b) @Id c) @GeneratedValue d) @KeyGenerator Answer: c) @GeneratedValue Explanation: The @GeneratedValue annotation is used in JPA to automatically generate primary key values. This annotation is applied to the primary key field of an entity and allows the database

Which annotation is used to automatically generate primary key values in JPA? Read More »

What does JPA stand for?

Java MCQ: What does JPA stand for? a) Java Persistence API b) Java Platform API c) Java Performance API d) Java Process API Answer: a) Java Persistence API Explanation: JPA stands for Java Persistence API. It is a specification in Java that provides a standard for object-relational mapping (ORM) and data persistence. JPA allows developers

What does JPA stand for? Read More »

Which method is used to rollback a transaction in JDBC?

Java MCQ: Which method is used to rollback a transaction in JDBC? a) undoTransaction() b) rollbackTransaction() c) rollback() d) revert() Answer: c) rollback() Explanation: The rollback() method is used to rollback a transaction in JDBC. When auto-commit mode is disabled, you can use rollback() on the Connection object to undo all changes made in the

Which method is used to rollback a transaction in JDBC? Read More »

Which JDBC method is used to commit a transaction?

Java MCQ: Which JDBC method is used to commit a transaction? a) commitTransaction() b) executeCommit() c) commit() d) finalizeTransaction() Answer: c) commit() Explanation: The commit() method is used to commit a transaction in JDBC. When auto-commit mode is disabled, multiple SQL statements can be grouped into a single transaction. After executing all the statements, calling

Which JDBC method is used to commit a transaction? Read More »

Which interface is used to execute SQL queries in JDBC?

Java MCQ: Which interface is used to execute SQL queries in JDBC? a) Statement b) ResultSet c) Connection d) PreparedStatement Answer: a) Statement Explanation: The Statement interface is used to execute SQL queries in JDBC. It provides methods to execute SQL statements, such as executeQuery() for SELECT statements, executeUpdate() for INSERT, UPDATE, and DELETE statements,

Which interface is used to execute SQL queries in JDBC? Read More »

Which method is used to establish a connection to a database?

Java MCQ: Which method is used to establish a connection to a database? a) DriverManager.connect() b) DriverManager.getConnection() c) Connection.create() d) Database.connect() Answer: b) DriverManager.getConnection() Explanation: The DriverManager.getConnection() method is used to establish a connection to a database in JDBC. This method takes a database URL, a username, and a password as arguments and returns a

Which method is used to establish a connection to a database? Read More »

What does JDBC stand for?

Java MCQ: What does JDBC stand for? a) Java Data Connection b) Java Database Connectivity c) Java DataBase Compiler d) Java Data Component Answer: b) Java Database Connectivity Explanation: JDBC stands for Java Database Connectivity. It is an API in Java that allows developers to connect to and interact with databases from Java applications. JDBC

What does JDBC stand for? Read More »

Scroll to Top