Sem 1 Midterm
Sem 1 Midterm
Sem 1 Midterm
Review your answers, feedback, and question scores below. An asterisk (*) indicates
a correct answer.
Section 1
(Answer all questions in this section)
True
False (*)
Correct Correct
Correct Correct
4. PL/SQL can be used not only with an Oracle database, but also
with any kind of relational database. True or False? Mark for Review
(1) Points
True
False (*)
Correct Correct
Correct Correct
Section 1
(Answer all questions in this section)
Exception only
Executable only
Correct Correct
True
False (*)
Definition
Declarative (*)
Exception
Executable
Correct Correct
Section 2
(Answer all questions in this section)
Use a NOT NULL constraint when a variable must have a value (*)
Section 2
(Answer all questions in this section)
TO_CHAR
Implicit
Explicit (*)
Correct Correct
v_date := FROM_CHAR(v_char,'dd-Mon-YYYY');
v_date := v_char;
Correct Correct
V_FAMILY_NAME = SMITH;
v_family_name = SMITH;
v_family_name := SMITH;
Correct Correct
True
False (*)
Correct Correct
15. Which of the following are PL/SQL data types? (Choose three.)
Mark for Review
(1) Points
Scalar (*)
Composite (*)
Lexical
Delimiter
Correct Correct
Previous Page 3 of 10 Next Summary
Section 2
(Answer all questions in this section)
PLS_INTEGER
Scalar
LOB
Composite (*)
Correct Correct
college_name VARCHAR2(20):='Harvard';
v_count PLS_INTEGER:=0;
Correct Correct
18. A variable must have a value if NOT NULL is specified. True or
False? Mark for Review
(1) Points
True (*)
False
Correct Correct
Variable v_a is out of scope within the inner block and therefore cannot be
referenced.
Correct Correct
Neither block
Correct Correct
Section 2
(Answer all questions in this section)
We cannot reference the outer block's variable because both variables have
the same name
v_myvar(outer_block) := 22;
<< outer_block>>.v_myvar := 22
v_myvar := 22;
Correct Correct
*/ / *
? ?
/* */ (*)
:: ::
Correct Correct
A type of variable
Correct Correct
True (*)
False
Correct Correct
25. Constants must be initialized. True or False? Mark for Review
(1) Points
True (*)
False
Correct Correct
Section 2
(Answer all questions in this section)
To comment code.
Correct Correct
Section 3
(Answer all questions in this section)
The block will fail because the SELECT statement returns more than one row.
The block will execute successfully, and the V_SALARY variable will be set to
NULL.
The block will fail because V_LAST was declared before V_FIRST.
The block will fail because the SELECT is trying to read two columns into
three PL/SQL variables. (*)
Correct Correct
No employees earn more than $50000. Which of the following statements are true?
(Choose two). Mark for Review
(1) Points
The SELECT will fail because it does NOT return exactly one row.
The block will fail because no results are displayed to the user.
The block will fail because variable V_SALARY was not declared.
SELECT *
INTO v_holdit
FROM employees;
SELECT last_name
INTO v_holdit
FROM employees;
SELECT last_name
INTO v_holdit
FROM employees
WHERE employee_id=100;
(*)
SELECT salary
INTO v_holdit
FROM employees
WHERE employee_id=100;
Correct Correct
30. Which of the following will delete all employees who work in the
Sales department? Mark for Review
(1) Points
Correct Correct
Section 3
(Answer all questions in this section)
You cannot use inequality operators such as "<" and ">" inside a DELETE
statement.
Correct Correct
One (*)
Two; both the INSERTs are one transaction and both the UPDATEs are a second
transaction.
You have nothing new; the last ROLLBACK undid the INSERTs.
You have the rows added twice; there are four new rows.
34. Assume there are 5 employees in Department 10. What happens when
the following statement is executed?
UPDATE employees
SET salary=salary*1.1;
Mark for Review
(1) Points
An error message is displayed because you must use the INTO clause to hold
the new salary.
No rows are modified because you did not specify "WHERE department_id=10"
Correct Correct
35. Which SQL statement can NOT use an implicit cursor? Mark for
Review
(1) Points
A DELETE statement
An UPDATE statement
Correct Correct
Section 3
(Answer all questions in this section)
36. A PL/SQL block contains the following DML statement:
UPDATE wf_countries
SET population = population * 1.1
WHERE country_id = 229;
Which kind of cursor is used for this statement? Mark for Review
(1) Points
An explicit cursor which must be declared and named by the PL/SQL programmer.
Correct Correct
Section 4
(Answer all questions in this section)
37. In the following code fragment, you want to exit from the outer
loop at Line A if v_number = 6. Which statement would you write on Line A?
<< big_loop >>
WHILE condition_1 LOOP
<< small_loop >>
FOR i IN 1..10 LOOP
DBMS_OUTPUT.PUT_LINE(i);
-- Line A
END LOOP;
END LOOP;
Mark for Review
(1) Points
Correct Correct
38. When the following code is executed, how many lines of output
will be displayed?
BEGIN
FOR i IN 1..5 LOOP
FOR j IN 1..8 LOOP
DBMS_OUTPUT.PUT_LINE(i || ',' || j);
END LOOP;
DBMS_OUTPUT.PUT_LINE(i);
END LOOP;
END;
45 (*)
41
80
14
Correct Correct
39. You should use a WHILE loop when the number of iterations of the
loop is known in advance. True or False? Mark for Review
(1) Points
True
False (*)
Correct Correct
If today's date is 17th April 2007, what will be displayed when this block
executes?
17-Apr-2007
01-May-2007
30-Apr-2007 (*)
31-Dec-2007
Correct Correct
Section 4
(Answer all questions in this section)
teenager
adult (*)
child
adultteenagerchild
Correct Correct
CASE statements
CASE expressions
Loops (*)
IF statements
Correct Correct
Correct Correct
MIDDLE
LOW (*)
HIGH
Null
Correct Correct
Section 4
(Answer all questions in this section)
46. What value will v_answer contain after the following code is
executed?
DECLARE
v_age NUMBER:= 18;
v_answer VARCHAR2(10);
BEGIN
v_answer :=
CASE
WHEN v_age < 25 THEN 'Young'
WHEN v_age = 18 THEN 'Exactly 18'
ELSE 'Older'
END;
Mark for Review
(1) Points
Older
Young (*)
Exactly 18
Null
Correct Correct
IF 'A' THEN
WHEN v_grade = 'A' THEN
Correct Correct
An infinite loop
A WHILE loop
A FOR loop
A nested loop
Correct Correct
What will be displayed when this block is executed? Mark for Review
(1) Points
11
xxxxxxxxxxx
10 (*)
Correct Correct
CASE loop
IF-THEN loop
WHILE loop
FOR loop
Correct Correct