0

programming languages Online Quiz - 61

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

The statement that is used to replace multiple if statement is called

  1. The switch & case statement

  2. ?:(ternary operator)

  3. The nestedif statement

  4. The #endif Statement


Correct Option: A

AI Explanation

To answer this question, you need to understand the concept of conditional statements in programming.

Option A) The switch & case statement - This option is correct. The switch & case statement is used to replace multiple if statements in programming. It allows you to evaluate a variable or expression against multiple values and execute different blocks of code based on the matching value.

Option B) ?:(ternary operator) - The ternary operator is a shortcut for writing simple if-else statements, but it is not used to replace multiple if statements.

Option C) The nested if statement - The nested if statement is used when you have multiple if statements inside each other, but it does not replace multiple if statements.

Option D) The #endif Statement - The #endif statement is used in preprocessor directives, specifically in conditional compilation, and it does not replace multiple if statements.

The correct answer is A) The switch & case statement. This option is correct because it is used to replace multiple if statements in programming.

What is the default access specifier for a top-level Class, which are not nested into other classes?

  1. Public

  2. Private

  3. Protected

  4. Internal


Correct Option: D

The following code will generate a comiler error. Which of the following statement inserted as the last line of the function ,would solve the problem?

  1. continue;

  2. break;

  3. return "Infant";

  4. return 0;

  5. return;


Correct Option: C

If a method is marked as protected internal who can access it?

  1. Access is limited to the current assembly.

  2. Access is limited to the containing class or types derived from the containing class.

  3. Access is limited to the containing type

  4. Access is limited to the current assembly or types derived from the containing class


Correct Option: D

AI Explanation

To answer this question, we need to understand the access modifiers in C#.

In C#, the protected internal access modifier allows access to the method from within the same assembly or from types derived from the containing class.

Let's go through each option to determine which one is correct:

Option A) Access is limited to the current assembly - This option is incorrect. The protected internal access modifier allows access not only to the current assembly but also to types derived from the containing class.

Option B) Access is limited to the containing class or types derived from the containing class - This option is incorrect. The protected internal access modifier allows access not only to the containing class but also to the current assembly.

Option C) Access is limited to the containing type - This option is incorrect. The protected internal access modifier allows access not only to the containing type but also to the current assembly and types derived from the containing class.

Option D) Access is limited to the current assembly or types derived from the containing class - This option is correct. The protected internal access modifier allows access to the method from within the same assembly or from types derived from the containing class.

Therefore, the correct answer is D.

The default type of enum is integer and has a default value 1

  1. True

  2. False


Correct Option: B
  1. true

  2. false

  3. an exception is thrown

  4. None of these


Correct Option: C
  1. string s= #"Test string";

  2. string s= ."Test string";

  3. string s= @"Test string";

  4. string s= &"Test string";


Correct Option: C

Can multiple catch blocks be executed for single try statement?

  1. True

  2. False


Correct Option: B
  1. Mapping files

  2. http.conf

  3. XML Configuration hibernate.cfg.xml

  4. web.config


Correct Option: A,C

Which of the following is FALSE about Session in hibernate

  1. Session is a light weight non-threadsafe object

  2. You can share the session between threads

  3. Session represents a single unit-of-work with the database

  4. Session is the primary interface for the persistence service

  5. A session loads database connections using lazy-loading


Correct Option: B

AI Explanation

To answer this question, we need to understand the concept of a Session in Hibernate.

A Session in Hibernate represents a single unit-of-work with the database. It is the primary interface for the persistence service and is used to perform database operations such as saving, updating, and deleting objects.

Now, let's go through each option to determine which one is FALSE:

Option A) Session is a lightweight non-threadsafe object - This option is TRUE. A Session in Hibernate is a lightweight object that is not thread-safe. It should not be shared between multiple threads.

Option B) You can share the session between threads - This option is FALSE. As mentioned earlier, a Session in Hibernate is not thread-safe and should not be shared between threads.

Option C) Session represents a single unit-of-work with the database - This option is TRUE. A Session represents a single database transaction and is used to perform a specific unit of work with the database.

Option D) Session is the primary interface for the persistence service - This option is TRUE. The Session interface is the primary interface for interacting with the persistence service in Hibernate.

Option E) A session loads database connections using lazy-loading - This option is FALSE. A Session in Hibernate does not directly load database connections. Instead, it loads and manages persistent objects from the database using lazy-loading or eager-loading strategies.

Therefore, the FALSE statement about a Session in Hibernate is option B) You can share the session between threads.

  1. DTD

  2. JDBC Connection

  3. SQL Variant to generate

  4. Mapping files

  5. Size of the database


Correct Option: A,B,C,D
  1. Holds a mandatory (first-level) cache of persistent objects, used when navigating the object graph or looking up objects by identifier

  2. Created during application initialization

  3. Wraps a JDBC connection

  4. Act as session Factory


Correct Option: C
  1. Create HQL Query

  2. Execute query to get list containing Java objects

  3. Load the Hibernate configuration file and create configuration object

  4. Create session from configuration object

  5. Get one session from the session factory


Correct Option: A,B,C,E
  1. Session.saveorupdate()

  2. Session.remove()

  3. Session.load()

  4. Session.save()


Correct Option: B

What are the benefits of ORM and Hibernate?

  1. Productivity

  2. Maintainability

  3. Vendor dependence

  4. Performance


Correct Option: A,B,D
  1. filename.hbm.xml

  2. filename.cfg.xml

  3. filename.hmb.xml

  4. filename.cfg.hbm.xml


Correct Option: A
- Hide questions