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

Which of the following is not a C# Keyword?

  1. Implements

  2. public

  3. delegate

  4. if


Correct Option: A

AI Explanation

To answer this question, we need to understand the concept of C# keywords. C# keywords are reserved words that have a specific meaning and cannot be used as identifiers (such as variable names or function names).

Let's go through each option to determine which one is not a C# keyword:

Option A) Implements - This option is incorrect because "implements" is a C# keyword. It is used when implementing an interface in a class.

Option B) public - This option is incorrect because "public" is a C# keyword. It is an access modifier that allows members to be accessed from outside the class.

Option C) delegate - This option is incorrect because "delegate" is a C# keyword. It is used to define a delegate, which is a type that represents references to methods with a specific parameter list and return type.

Option D) if - This option is incorrect because "if" is a C# keyword. It is used to perform conditional statements in C#.

Based on the explanations above, the correct answer is not provided in the given options. All options A, B, C, and D are C# keywords.

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

Unboxing of null reference type will return a null

  1. true

  2. false

  3. an exception is thrown

  4. None of these


Correct Option: C

AI Explanation

To answer this question, we need to understand the concept of null reference types in programming.

In programming languages that support null reference types (such as C#), a null reference represents the absence of an object. When unboxing is performed on a null reference type, an exception is thrown.

Option A) true - This option is incorrect because unboxing a null reference type does not return a null. Instead, it throws an exception.

Option B) false - This option is incorrect because unboxing a null reference type does not return false. Instead, it throws an exception.

Option C) an exception is thrown - This option is correct. Unboxing a null reference type will result in an exception being thrown.

Option D) None of these - This option is incorrect because option C is the correct answer.

Therefore, the correct answer is C) an exception is thrown.

Which of these string definition will prevent escaping on backslashes in 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

Which of the following are most common configuration methods of Hibernate Configuation

  1. Mapping files

  2. http.conf

  3. XML Configuration hibernate.cfg.xml

  4. web.config


Correct Option: A,C

AI Explanation

To answer this question, you need to understand the common configuration methods of Hibernate.

Option A) Mapping files - This option is correct because mapping files are one of the most common configuration methods in Hibernate. These files define the mapping between Java classes and database tables.

Option B) http.conf - This option is incorrect. The http.conf file is a configuration file used by the Apache HTTP Server, not Hibernate.

Option C) XML Configuration hibernate.cfg.xml - This option is correct because hibernate.cfg.xml is another common configuration method in Hibernate. This XML file contains the configuration settings for the Hibernate framework.

Option D) web.config - This option is incorrect. The web.config file is a configuration file used in ASP.NET applications, not Hibernate.

The correct answers are A) Mapping files and C) XML Configuration hibernate.cfg.xml. These options are correct because they are commonly used configuration methods in Hibernate.

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.

Which of the following are tags of hibernate.cfg.xml? Select all that apply

  1. DTD

  2. JDBC Connection

  3. SQL Variant to generate

  4. Mapping files

  5. Size of the database


Correct Option: A,B,C,D

AI Explanation

To answer this question, we need to understand what the tags in the hibernate.cfg.xml file represent.

Option A) DTD - This option is correct. The `tag in thehibernate.cfg.xml` file specifies the DTD (Document Type Definition) for the Hibernate configuration file.

Option B) JDBC Connection - This option is correct. In the hibernate.cfg.xml file, the `` tag can be used to configure the JDBC connection properties, such as the database URL, username, password, etc.

Option C) SQL Variant to generate - This option is correct. The `` tag can also be used to specify the SQL dialect or variant to be used by Hibernate for generating the SQL queries.

Option D) Mapping files - This option is correct. The `tag is used in thehibernate.cfg.xml` file to specify the mapping files that define the object-relational mapping between Java classes and database tables.

Option E) Size of the database - This option is incorrect. The size of the database is not a tag in the hibernate.cfg.xml file.

The correct answers are A) DTD, B) JDBC Connection, C) SQL Variant to generate, and D) Mapping files.

There are core interfaces are used in just about every Hibernate application. Using these interfaces, you can store and retrieve persistent objects and control transactions. Select all the interfaces that you see

  1. Configuration interface

  2. Session interface

  3. Query and Criteria interfaces

  4. User interface


Correct Option: A,B,C

AI Explanation

To answer this question, you need to understand the core interfaces used in Hibernate applications. Let's go through each option to understand which interfaces are correct or incorrect:

Option A) Configuration interface - This option is correct. The Configuration interface is used to configure Hibernate and set up the mapping between Java classes and database tables.

Option B) Session interface - This option is correct. The Session interface is used to create, read, update, and delete persistent objects. It represents a single unit of work with the database.

Option C) Query and Criteria interfaces - This option is correct. The Query and Criteria interfaces are used to perform database queries and retrieve data from the database.

Option D) User interface - This option is incorrect. The User interface is not a core interface used in Hibernate applications.

The correct answer is A, B, C. These interfaces are commonly used in Hibernate applications for storing and retrieving persistent objects and controlling transactions.

Which of the following is NOT a role of the session interface?

  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

Which of the following is NOT a step in the Hibernate communication with RDBMS?

  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

AI Explanation

To answer this question, you need to understand the steps involved in Hibernate communication with RDBMS.

Let's go through each option to understand why it is correct or incorrect:

Option A) Create HQL Query - This option is incorrect because creating an HQL (Hibernate Query Language) query is indeed a step in Hibernate communication with RDBMS. HQL is a language similar to SQL but specifically designed for querying Hibernate-managed entities.

Option B) Execute query to get list containing Java objects - This option is incorrect because executing a query to retrieve a list of Java objects is another step in Hibernate communication with RDBMS. Hibernate translates the HQL query into SQL and executes it against the database to retrieve the desired data.

Option C) Load the Hibernate configuration file and create configuration object - This option is incorrect because loading the Hibernate configuration file and creating a configuration object is an essential step in Hibernate communication with RDBMS. The configuration file contains information about the database connection, mapping information, and other Hibernate-specific settings.

Option D) Create session from configuration object - This option is correct because creating a session from the configuration object is indeed a step in Hibernate communication with RDBMS. The session represents a single-threaded context for executing database operations.

Option E) Get one session from the session factory - This option is incorrect because getting a session from the session factory is also a step in Hibernate communication with RDBMS. The session factory is responsible for creating and managing sessions.

Based on the above analysis, the correct answer is option A,B,C,E.

Which of the following is not a Session method?

  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

What is the file extension you use for hibernate mapping file?

  1. filename.hbm.xml

  2. filename.cfg.xml

  3. filename.hmb.xml

  4. filename.cfg.hbm.xml


Correct Option: A

Below Code is TRUE (=Correct)/FALSE (=Wrong)? BEGIN SELECT PROJECT_ID FROM PA_PROJECTS_ALL WHERE PROJECT_ID IN (12345); END;

  1. True

  2. False


Correct Option: A

WCF service author Can configure authorization with PrincipalPermissionMode setting in ServiceAuthorization behavior. Please select the invalid for?

  1. UseWindowsGroups

  2. UseAspNetRoles

  3. UseNetworkUser

  4. None


Correct Option: C
- Hide questions