- Given i= 0, j = 1, k = – 1
x = 0.5, y = 0.0
What is the output of given ‘C’ expression ?
x * 3 & & 3 || j | k
(A) -1 (B) 0
(C) 1 (D) 2
Answer: C
Explanation:
⇒⇒(x*3)&&3 || j | k
⇒⇒0&&3 || (j | k)
⇒⇒0&&3 || 1
⇒⇒(0&&3) || 1
⇒⇒ 0||1
⇒⇒1
- The following ‘C’ statement :
int * f[ ]( );
declares :
(A) A function returning a pointer to an array of integers.
(B) Array of functions returning pointers to integers.
(C) A function returning an array of pointers to integers.
(D) An illegal statement.
Answer: C
Explanation:
f is an array of integer pointers and return type of a function
int * f[] () as we can see that return type of function is an array of pointers i.e. f
- If a function is friend of a class, which one of the following is wrong ?
(A) A function can only be declared a friend by a class itself.
(B) Friend functions are not members of a class, they are associated with it.
(C) Friend functions are members of a class.
(D) It can have access to all members of the class, even private ones.
Answer: C
Explanation:
friend function is not a member of class it works as a bridge between Two classes.
- In C++, polymorphism requires:
(A) Inheritance only
(B) Virtual functions only
(C) References only
(D) Inheritance, Virtual functions and references
Answer: D
Explanation:
Polymorphism requires inheritance, Virtual functions and references
- A function template in C++ provides ………… level of generalization.
(A) 4 (B) 3
(C) 2 (D) 1
Answer: C
Explanation:
C++ templates can be used both for classes and for functions in C++. Templated functions are actually a bit easier to use than templated classes, as the compiler can often deduce the desired type from the function’s argument list.
template <class type> type func_name(type arg1, ...);
For instance, to declare a templated function to add two values together, you could use the following syntax:
template <class type> type add(type a, type b)
{
return a + b;
}
- DBMS provides the facility of accessing data from a database through
(A) DDL (B) DML
(C) DBA (D) Schema
Answer: B
Explanation:
DDL
Data Definition Language (DDL) statements are used to define the database structure or schema. Some examples:
- CREATE – to create objects in the database
- ALTER – alters the structure of the database
- DROP – delete objects from the database
- TRUNCATE – remove all records from a table, including all spaces allocated for the records are removed
- COMMENT – add comments to the data dictionary
- RENAME – rename an object
DML
Data Manipulation Language (DML) statements are used for managing data within schema objects. it provides the facility of accessing data from a database. Some examples:
- SELECT – retrieve data from the a database
- INSERT – insert data into a table
- UPDATE – updates existing data within a table
- DELETE – deletes all records from a table, the space for the records remain
- MERGE – UPSERT operation (insert or update)
- CALL – call a PL/SQL or Java subprogram
- EXPLAIN PLAN – explain access path to data
- LOCK TABLE – control concurrency
DCL
Data Control Language (DCL) statements. Some examples:
- GRANT – gives user’s access privileges to database
- REVOKE – withdraw access privileges given with the GRANT command
TCL
Transaction Control (TCL) statements are used to manage the changes made by DML statements. It allows statements to be grouped together into logical transactions.
- COMMIT – save work done
- SAVEPOINT – identify a point in a transaction to which you can later roll back
- ROLLBACK – restore database to original since the last COMMIT
- SET TRANSACTION – Change transaction options like isolation level and what rollback segment to use
- Relational database schema normalization is NOT for:
(A) reducing the number of joins required to satisfy a query.
(B) eliminating uncontrolled redundancy of data stored in the database.
(C) eliminating number of anomalies that could otherwise occur with inserts and deletes.
(D) ensuring that functional dependencies are enforced.
Answer: A
- Consider the following statements regarding relational database model:
(a) NULL values can be used to opt a tuple out of enforcement of a foreign key.
(b) Suppose that table T has only one candidate key. If Q is in 3NF, then it is also in BCNF.
(c) The difference between the project operator (P) in relational algebra and the SELECT keyword in SQL is that if the resulting table/set has more than one occurrences of the same tuple, then P will return only one of them, while SQL SELECT will return all.
One can determine that:
(A) (a) and (b) are true. (B) (a) and (c) are true.
(C) (b) and (c) are true. (D) (a), (b) and (c) are true.
Answer: D
- Consider the following Entity-Relationship (E-R) diagram and three possible relationship sets (I, II and III) for this E-R diagram:
If different symbols stand for different values (e.g., t1 is definitely not equal to t2), then which of the above could not be the relationship set for the E-R diagram ?
(A) I only (B) I and II only
(C) II only (D) I, II and III
Answer: A
Explanation:
We know that cardinalty constraints on more-than-binary relationship with more than one arrow (1 sides) creates ambiguity in ER diagram. [For more info on this, please refer to the DBMS book by Korth]
The given ER diagram can mean any one of the following two cases:
Case 1: PQ → ST
Case 2: PQS → T and PQT → S
Now, going through the three instances, we can identify the FDs and non-FDs satisfied for the instances as follows:
Instance 1:
PQ ↛ T (so, case 1 isnot valid)
PQS ↛ T (so, case 2 is also not vaid)
So, the ER-diagram can NOT be a representation of Instance 1.
Instance 2:
PQ ↛ S and PQ ↛ T (so, case 1 is not valid)
However, PQS → T and PQT → S (so, case 2 is valid)
So, the ER-diagram can be a representation of Instance 2.
Instance 3:
PQ → S and PQ → T as well (so, case 1 is valid)
Validy of case 1 ensures validity of the FDs in case 2 as well.
So, the ER-diagram can also be a representation of Instance 3.
Therefore, correct answer is (A) I only.
ref:techtud
- Consider a database table R with attributes A and B. Which of the following SQL queries is illegal ?
(A) SELECT A FROM R;
(B) SELECT A, COUNT(*) FROM R;
(C) SELECT A, COUNT(*) FROM R GROUP BY A;
(D) SELECT A, B, COUNT(*) FROM R GROUP BY A, B;
Answer: B
Explanation:
Aggregate functions,grouping attribute must be used with group by clause.