0

programming languages Online Quiz - 70

Description: programming languages Online Quiz - 70
Number of Questions: 20
Created by:
Tags: programming languages
Attempted 0/20 Correct 0 Score 0

Batch fetching is useful incase of ?

  1. lazy="true"

  2. lazy="false"

  3. lazy="on"

  4. lazy="off"


Correct Option: A

what is the default value in hibernate ?

  1. lazy=false;

  2. lazy=true;

  3. lazy=yes;

  4. lazy=no;


Correct Option: B

HQL is used in ?

  1. session.createQuery();

  2. session.createCriteria();

  3. session.createSQLQuery();

  4. session.lod();


Correct Option: A
  1. NULL

  2. Empty Object

  3. Unrecoverable exception

  4. None of the above


Correct Option: C

Does hibernate require persistent classes to implement Serializable?

  1. Required

  2. Not Required

  3. None of the above

  4. None


Correct Option: B

What does CacheMode do ?

  1. controls how a particular SessionFactory interacts with the Data Base.

  2. controls how a particular SessionFactory interacts with the second-level cache.

  3. controls how a particular session interacts with the second-level cache.

  4. None


Correct Option: C

If instances are not in the session or second-level cache which will give better performance?

  1. Query.list()

  2. Query.iterate()

  3. Both are same

  4. None of the above


Correct Option: A

AI Explanation

To answer this question, we need to understand the difference between Query.list() and Query.iterate() in Hibernate, a popular Java-based ORM (Object-Relational Mapping) framework.

Option A) Query.list() - This option is correct because it retrieves all the instances that match the criteria specified in the query and returns a list of those instances. The retrieved instances are loaded into memory, and subsequent access to the instances does not require any additional database round-trips. This can lead to better performance when instances are not in the session or second-level cache.

Option B) Query.iterate() - This option is incorrect because it returns an iterator over the instances that match the query criteria. The instances are loaded one by one as they are accessed, and each access requires a database round-trip to retrieve the instance. This can result in additional overhead and slower performance compared to Query.list(), especially when instances are not in the session or second-level cache.

Option C) Both are the same - This option is incorrect because Query.list() and Query.iterate() have different behaviors and performance characteristics, as explained above.

Option D) None of the above - This option is incorrect because Option A, Query.list(), is the correct answer as it provides better performance when instances are not in the session or second-level cache.

Therefore, the correct answer is Option A, Query.list(), because it gives better performance when instances are not in the session or second-level cache.

What does sess.delete() do?

  1. a) remove data from in memory

  2. b) remove from database.

  3. c) remove from sessionFactory

  4. d) None of the above.


Correct Option: B
Explanation:

To understand what sess.delete() does, we need to know that it is a method used in SQLAlchemy, which is a Python library for working with SQL databases.

The sess.delete() method is used to delete an object from the database using the SQLAlchemy session object that it is called on.

Now let's go through each option and explain why it is right or wrong:

A. a) remove data from in-memory: This option is incorrect because calling sess.delete() does not remove data from in-memory, it only marks the object for deletion from the database.

B. b) remove from the database: This option is correct. Calling sess.delete() method marks the object for deletion from the database. The object is only removed from the database when the session is committed.

C. c) remove from sessionFactory: This option is incorrect because sess.delete() method does not remove an object from the sessionFactory.

D. d) None of the above: This option is incorrect because option B is correct.

Therefore, the answer is: B. remove from the database.

How can a whole class be mapped as immutable?

  1. By using the mutable="false" attribute in the class mapping.

  2. By using the ismutable="false" attribute in the class mapping.

  3. By using the ismutable="no" attribute in the class mapping

  4. None


Correct Option: A

what does hibernate.hbm2ddl.auto create this means ?

  1. create tables automatically

  2. create session object automatically

  3. create Session Factory object automatically

  4. None


Correct Option: A
Explanation:

The hibernate.hbm2ddl.auto property is used to automatically create database tables based on the entity classes defined in the Hibernate configuration file.

Option A is correct. When set to create, the hibernate.hbm2ddl.auto property creates the necessary tables in the database based on the entity classes defined in the Hibernate configuration file.

Option B is incorrect. The hibernate.hbm2ddl.auto property doesn't create session objects automatically.

Option C is incorrect. The hibernate.hbm2ddl.auto property doesn't create Session Factory objects automatically.

Option D is incorrect. There is a functionality associated with the hibernate.hbm2ddl.auto property.

Therefore, The Answer is A.

Employee emp = session.load(Employee .class);

  1. Yes

  2. No

  3. None

  4. None of the above


Correct Option: B

AI Explanation

To answer this question, we need to understand what the code session.load(Employee.class) does.

In Hibernate, the load() method is used to retrieve an entity object from the database based on its identifier. It returns a proxy object of the requested entity class.

In the given code, Employee.class represents the class of the entity we want to retrieve. The session.load(Employee.class) method retrieves the Employee entity object from the database.

Now, let's go through each option:

Option A) Yes - This option is incorrect. The code session.load(Employee.class) will return a proxy object of the Employee class, not a fully-initialized entity object.

Option B) No - This option is correct. The code session.load(Employee.class) will return a proxy object of the Employee class, not a fully-initialized entity object.

Option C) None - This option is incorrect. The code session.load(Employee.class) will return a proxy object of the Employee class.

Option D) None of the above - This option is incorrect. Option B is the correct answer.

The correct answer is Option B) No. The code session.load(Employee.class) returns a proxy object of the Employee class, not a fully-initialized entity object.

____ forces hibernate to bypass the setter method and access the instance variable directly while initializing a newly loaded object.

  1. By mapping the property with access="onlyfield" in Hibernate metadata

  2. By mapping the property with access="variable" in Hibernate metadata

  3. By mapping the property with access="field" in Hibernate metadata

  4. none of the above


Correct Option: C

Difference between Emp e = session.load(Emp.class) and Emp e = session.createCriteria(Emp.class) ?

  1. On session close session.load() Emp Object unavailable to access.

  2. On session close session.createCriteria() Emp unavailable to access.

  3. None

  4. a & b


Correct Option: A

Which of the following is true?

  1. 1

  2. 66

  3. .1

  4. -1

  5. All of the above


Correct Option: E

What does 7/9*9 equal (in C and C++)?

  1. 1

  2. 0.08642

  3. 0

  4. 7


Correct Option: C

Which of the following is evaluated first:

  1. &&

  2. ||

  3. !

  4. &&&


Correct Option: C

If you continuously increment a variable, it will become negative?

  1. True

  2. False

  3. Cannot continuously increment a variable

  4. It depends on the variable type


Correct Option: D

Which of the following data structures is on average the fastest for retrieving data:

  1. Binary Tree

  2. Hash Table

  3. Stack

  4. Queue


Correct Option: B

What is the output of the following code: int v() { int m=0; return m++; } int main() { cout<

  1. 1

  2. 0

  3. Code cannot compile

  4. Run time error


Correct Option: B

Which of the following sorts is quickest when sorting the following set: 1 2 3 5 4

  1. Bubble Sort

  2. Quick Sort

  3. Merge Sort

  4. Radix Sort


Correct Option: A
- Hide questions