Question Bank
Given R defined in the previous question, which of the below statements are false?
Previous question:
The table below contains a representative data sample for all the functional dependencies in a real-life data set. Which are the functional dependencies that hold for the data below?
The relation R is in the first normal form.
The relation R is in the second normal form.
In the relation R the values in column B determines the values in column A.
The relation R can not contain two tuples with different values in column D when the values in column A match.
Given the E/R diagram below Which of the following relations appear in the relational model representation of the diagram?

Courses(CID, title)
Students(SID, name)
Enroll(SID,CID)
Enroll(SID, name, CID, title, grade)
Students(SID, name, CID)
Enroll(SID, CID, grade)
The table EMPLOYEES contains 10 employees, each having the salary = 1000 euro, with one exception - an employee has the salary set to NULL. The first 5 employees work in department 1 and the other 5 in department 2. How many rows will return the following query?
SELECT department_id, SUM(salary)
FROM employees
GROUP BY department_id
HAVING SUM(NVL(salary,1000)) > 4000;No rows (empty)
One row
Two row
Other variant
Which of the following queries returns the identifier (ID) and the name of all departments without any employee? Assume that the column DEPARTMENT_ID exists in both EMPLOYEES and DEPARTMENTS tables.
SELECT d.department_id, d.department_name
FROM departments d
WHERE NOT EXISTS (SELECT 1 FROM employees e WHERE e.department_id=d.department_id);SELECT d.department_id, d.department_name
FROM employees e LEFT OUTER JOIN departments d
ON (d.department_id=e.department_id) WHERE e.department_id IS NULL;SELECT d.department_id, d.department_name
FROM employees e RIGHT OUTER JOIN departments d
ON (d.department_id=e.department_id) WHERE e.department_id IS NULL;SELECT department_id, department_name
FROM departments
MINUS
SELECT d.department_id, d.department_name
FROM employees e JOIN departments d ON e.department_id=d.department_id;You want to display all the cities that have no departments and all the departments that have not been allocated to any city. Which type of join between DEPARTMENTS and LOCATIONS tables would produce this information as part of its output?
NATURAL JOIN
FULL OUTER JOIN
LEFT OUTER JOIN
RIGHT OUTER JOIN
Which statements are correct regarding indexes?
When a table is dropped, the corresponding indexes are automatically dropped.
For each DML operation performed, the corresponding indexes are automatically updated.
Indexes should be created on columns that are frequently referenced as part of an expression.
A PRIMARY KEY or a UNIQUE constraint in a table automatically creates a unique index.
The following SQL statement was written to retrieve the rows for the PRODUCT_ID that has a UNIT_PRICE greater than 1,000 and has been ordered more than five times:
SELECT product_id, COUNT(order_id) total, unit_price
FROM order_items
WHERE unit_price>1000 AND COUNT(order_id)>5
GROUP BY product_id, unit_price; Which statement is true regarding this SQL statement?
The statement would execute and give you the desired result.
The statement would not execute because the aggregate function is used in the WHERE clause.
The WHERE clause should have the OR logical operator instead of AND.
The statement would not execute because in the SELECT clause, the unit_price column is placed after the column having the aggregate function.
Which of the following queries will return the columns FIRST_NAME and SALARY of all employees who have the same manager (MANAGER_ID) as that of the employee with EMPLOYEE_ID = 101 and have a SALARY greater than or equal to the employee with EMPLOYEE_ID = 101?
SELECT first_name, salary
FROM employees
WHERE (manager_id, salary) >= ALL (SELECT manager_id, salary
FROM employees WHERE employee_id = 101)
AND employee_id <> 101;SELECT first_name, salary
FROM employees WHERE (manager_id, salary) >= (SELECT manager_id, salary
FROM employees
WHERE employee_id = 101)
AND employee_id <> 101;SELECT first_name, salary
FROM employees
WHERE (manager_id, salary) >= ANY (SELECT manager_id, salary
FROM employees
WHERE employee_id = 101 AND employee_id <> 101);SELECT first_name, salary
FROM employees WHERE manager_id = (SELECT manager_id
FROM employees WHERE employee_id = 101)
AND salary >= (SELECT salary
FROM employees
WHERE employee_id = 101)
AND employee_id <> 101;SELECT e.first_name, e.salary
FROM employees e, employees m
WHERE m.employee_id = 101 AND e.manager_id = m.manager_id
AND e.salary >= m.salary AND e.employee_id <> m.employee_id;Evaluate the CREATE TABLE statement:
CREATE TABLE products
(product_id NUMBER(6) CONSTRAINT prod_id_pk PRIMARY KEY,
product_name VARCHAR2(15)); Which statement is true regarding the PROD_ID_PK constraint?
It would be created only if a unique index is manually created first.
It would be created and would use an automatically created unique index.
It would be created and would use an automatically created non-unique index.
It would be created and remains in a disabled state because no index is specified in the command.
Given the view V below, when the WITH CHECK OPTION clause generates an exception?
UPDATE V SET Curs = ’Databases II’ WHERE ID=101;
CREATE VIEW V(ID, Course, EDate) AS
SELECT StudID, CourseTitle, EnrollmentDate
FROM Enrollments
WHERE CourseTitle=’Algebra’
AND Accepted=1 WITH CHECK OPTION;always
only if the student with ID = 101 applied and he/she is accepted in the Algebra course
only if the student with ID = 101 applied and he/she is accepted in the Database II course
if the student with ID = 101 applied for Algebra course, regardless of the value of the Accepted column
What does data encapsulation refer to?
Encapsulation of specific expertise into a class
Hiding access to the private state of an object
Making all the attributes of a class private
Including no methods in a class but only attributes
Hiding access to the entire state of an object.
Which of the following statement(s) is/are FALSE for the Java language?
The multiple inheritance can be obtained by applying the simple inheritance by a number of times;
The simple inheritance can be simply obtained implementing a single interface
Only the abstract class can benefit from multiple inheritance
Multiple inheritance can be simulated by implementing multiple interfaces.
Which statement(s) from the ones below are true in relation with the Java language?
The final keyword applies to classes, attributes and methods
A final method can only call other final methods in the same class
A final method in a class cannot be overriden in subclasses
A final attribute can be set only once
Final attributes can only exist in final classes.
Which of the following assertion(s) hold in relation with the Java language?
Inheritance can always be replaced by objects’ composition
A class can implement any number of interfaces
Using objects’ composition provide a possibility to avoid access restrictions
Object composition is also referred as objects aggregation.
What is true about the String class in Java?
The content of a String cannot be modified after creation
The == operator is used to compare the content of two String objects
The String class is final
The String class has an attribute called size providing the length of the string
Which of the following statement(s) is/are true about a Java abstract class:
A class which cannot be instantiated
A class having at least an abstract method
A class defined using the abstract keyword
Which is the output of the following program?
public class MainClass {
void method(int ... a){
System.out.print(1 + " ");
}
void method(int[] a){
System.out.print(2+ " ");
}
public static void main(String args[]){
MainClass a = new MainClass();
a.method(new int[]{1,2,3,4});
}
}1
2
1 2
compilation error
execution error
Which of the following statement(s) is/are false about Collections and Collection?
Collections is a special type of collection which holds a Set of collection
Both Collection and Collections entity belongs to java.util package
Collections is a utility class
Collection is an interface to Set and List
Collection instances do not use erasure when are instantiated
Which of the following lines of code is suitable to start a thread?
class X implements Runnable {
public void run() {
System.out.println(“Thread is in Running state”);
}
public static void main(String args[]) {
/* Missing code? */
}
}X obj = new X()
Thread t=new Thread(obj);
t.start();X obj = new X()
Thread t=new Thread(X);X x= new X()
Thread t=new Thread();
x.run();Thread t=new Thread(X())
t.start();None of these
Thread t=new Thread(new X())
t.start();What is the result of the following statements?
List list = new ArrayList();
list.add("one");
list.add("two");
list.add(7);
6: for (String s: list)
7: System.out.print(s);onetwo
onetwo followed by an exception
Compiler error on line 6
Compiler error on line 7
Analyze the following code:
class A:
def __init__(self, s):
self.s = s
def print(self):
print(s)
a = A("Welcome")
a.print()The program has an error because class A does not have a constructor.
The program has an error because class A should have a print method with signature print(self, s).
The program has an error because class A should have a print method with signature print(s).
The program would run if the line print(s) is changed to print(self.s).
What is the result of the execution of the following code?
x = 2
for i in range(x):
x += 1
print (x)0 1 2 3 4 . . .
0 1
3 4
0 1 2 3
Which is the output of the following code?
names1 = [’Amir’, ’Barry’, ’Charles’, ’Dao’]
names2 = names1
names3 = names1[:]
names2[0] = ’Alice’
names3[1] = ’Bob’
sum = 0
for ls in (names1, names2, names3):
if ls[0] == ’Alice’:
sum += 1
if ls[1] == ’Bob’:
sum += 10 print(sum)
print(sum)11
12
21
22
33
0
Which of the following is/are features of DocString?
Provide a convenient way of associating documentation with Python modules, functions, classes, and methods
Provide a convenient way of associating documentation only with Python classes, and methods
All functions should have a docstring
Providing documentation to a application is time-waste
Docstrings can be accessed by the __doc__ attribute on objects
Which of the following statements are TRUE about generators (in Python): (this question was marked wrong by the commision)
Generators are lazy in nature
Generators are eager in nature
Generators could make your program to perform faster if the values are generated only once
Generators could make your program to perform faster if the values are generated multiple times
Generators could make your program to perform slower