1.
Can we have overloaded virtual functions?
Correct Answer
A. True
Explanation
Yes, we can have overloaded virtual functions. In object-oriented programming, a virtual function is a function that is declared in a base class and can be overridden by a derived class. Overloading a function means having multiple functions with the same name but different parameters. Therefore, it is possible to have multiple virtual functions with the same name but different parameters, resulting in overloaded virtual functions.
2.
Is “this” is a reference variable?
Correct Answer
B. False
Explanation
The statement "this" is not a reference variable. "this" is a keyword in Java that refers to the current object. It is used to differentiate between instance variables and parameters with the same name. It does not hold any value or reference to an object, so it cannot be considered a reference variable.
3.
Which is the highest precedence operator?
Correct Answer
()
Explanation
The parentheses operator () has the highest precedence in mathematical expressions. This means that any expression inside the parentheses is evaluated first before any other operation is performed. It is used to control the order of operations and can be used to override the default precedence rules.
4.
Oracle engine automatically locks table data while executing SQL statements
Correct Answer
A. True
Explanation
The given answer is true because Oracle engine automatically locks table data while executing SQL statements. This means that when a SQL statement is being executed, Oracle will lock the relevant table data to ensure data integrity and prevent concurrent access issues. This locking mechanism helps in maintaining the consistency and accuracy of the data being accessed or modified by multiple users or processes simultaneously.
5.
Is the below syntax is correct?
Exception
when OTHERS THEN
DBMS_OUTPUT.PUT_LINE("ERROR");
WHEN TOO-MANY-ROWS-FOUND THEN
DBMS_OUTPUT.PUT_LINE("MORE ROWS FOUND");
Correct Answer
B. False
Explanation
The given syntax is not correct. The keyword "Exception" should be replaced with "EXCEPTION" in PL/SQL. Additionally, the exception name "TOO-MANY-ROWS-FOUND" should be enclosed in double quotation marks. Therefore, the correct syntax would be:
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE("ERROR");
WHEN 'TOO-MANY-ROWS-FOUND' THEN
DBMS_OUTPUT.PUT_LINE("MORE ROWS FOUND");
Therefore, the answer is False.
6.
Can we define a class inside another class?
Correct Answer
A. True
Explanation
Yes, we can define a class inside another class. This is known as a nested class or inner class. The nested class is a way to logically group classes that are only used in one place and helps in better organization of code. The nested class has access to the members of the outer class, including private members, and can be instantiated within the outer class or outside of it.
7.
Static member variables of a class can be initialized by using Constructor?
Correct Answer
B. False
Explanation
Static member variables of a class cannot be initialized using a constructor. Constructor is used to initialize instance variables, which are specific to each object of the class. Static member variables, on the other hand, are shared among all objects of the class and are initialized separately using static initialization blocks or by directly assigning a value to them. Therefore, the statement is false.
8.
Which is the lowest precedence operator?
Correct Answer
,(comma)
Explanation
The lowest precedence operator is the comma (,). This operator is used to separate expressions or values in a list. It has the lowest precedence because it evaluates each expression from left to right, without any specific order of operations.
9.
There is a limit to the number of cursors that can be opened in a session.
Correct Answer
A. True
Explanation
The statement is true because in most database systems, there is a limit to the number of cursors that can be opened in a session. Cursors are used to retrieve and manipulate data from a result set, and opening too many cursors can consume significant system resources. Therefore, to prevent resource exhaustion and optimize performance, a limit is imposed on the number of cursors that can be opened in a session.
10.
Can we use a commit statement within a database trigger?
Correct Answer
B. False
Explanation
A commit statement is used to permanently save changes made in a transaction. However, using a commit statement within a database trigger is not allowed because triggers are automatically executed as part of a transaction. If a commit statement is used within a trigger, it would cause the trigger to be fired again, resulting in an infinite loop. Therefore, it is not possible to use a commit statement within a database trigger.
11.
Can constructor throw an exception?
Correct Answer
A. True
Explanation
Yes, a constructor can throw an exception. When a constructor encounters an error or a condition that prevents it from properly initializing an object, it can throw an exception to indicate the failure. This allows the caller of the constructor to handle the exception and take appropriate action. Exceptions thrown in a constructor can be caught using try-catch blocks, allowing for error handling and graceful recovery. Therefore, the statement "True" is correct.
12.
Can we have duplicate cases in the switch?
Correct Answer
B. False
Explanation
In a switch statement, each case must be unique. If there are duplicate cases, it will result in a compilation error. Each case is used to match a specific value, and if there are duplicates, it would create ambiguity in the code and make it unclear which case should be executed. Therefore, duplicate cases are not allowed in a switch statement.
13.
Can we have virtual constructors?
Correct Answer
B. False
Explanation
Virtual constructors are not possible in most programming languages. Constructors are special member functions that are used to initialize objects of a class. They are called automatically when an object is created. However, virtual functions are used for dynamic polymorphism, allowing derived classes to override the behavior of base class functions. Constructors cannot be virtual because they are called during object creation, before the object's type is determined. Therefore, the answer is false.
14.
Can we write trigger on views?
Correct Answer
A. True
Explanation
Yes, we can write triggers on views. A trigger is a special type of stored procedure that automatically executes when an event (such as an insert, update, or delete) occurs on a table or view. Triggers can be used to enforce business rules, perform data validation, or update other tables/views based on the changes made to the underlying data. Therefore, it is possible to create triggers on views to perform specific actions whenever data in the view is modified.
15.
IN is faster than EXISTS.
Correct Answer
B. False
Explanation
The statement "IN is faster than EXISTS" is false. In SQL, the EXISTS keyword is generally faster than using the IN operator. The EXISTS keyword checks for the existence of a subquery result, while the IN operator compares a value with a set of values. The EXISTS keyword stops evaluating as soon as it finds a match, while the IN operator evaluates all the values in the set. Therefore, when dealing with large datasets, using EXISTS can result in better performance compared to using IN.
16.
42 is the ASCII value of '\0'
Correct Answer
B. False
Explanation
The ASCII value of '\0' is actually 0, not 42. Therefore, the statement that 42 is the ASCII value of '\0' is false.
17.
Can we call the destructor explicitly?
Correct Answer
A. True
Explanation
Yes, we can call the destructor explicitly in C++. This can be done by using the delete keyword followed by the object's name. However, it is generally not recommended to call the destructor explicitly unless there is a specific need, as the destructor is automatically called when an object goes out of scope or is deleted. Calling the destructor explicitly can lead to undefined behavior if the object is accessed after its destruction.
18.
Can we overload '->' operator?
Correct Answer
B. False
Explanation
The '-' operator in C++ cannot be overloaded. It is a built-in operator and its behavior cannot be changed. Overloading operators is only possible for certain operators such as arithmetic, comparison, and assignment operators.
19.
The name of the table can be changed using the ALTER TABLE clause.
Correct Answer
B. False
Explanation
The name of the table cannot be changed using the ALTER TABLE clause.
20.
Check constraint consists of subqueries and sequences.
Correct Answer
B. False
Explanation
The given statement is incorrect. Check constraints do not consist of subqueries and sequences. Check constraints are used to enforce specific conditions on the values entered into a column. They can be used to ensure that only certain values are allowed in a column or to restrict the range of values that can be entered. Subqueries and sequences are not directly related to check constraints.