Section 1

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 14

Section 1

(Answer all questions in this section)




1. Comparing PL/SQL with other languages such as C and Java, which of the
following statements is true?
Mark for Review
(1) Points


PL/SQL is harder to learn




PL/SQL is easier to learn and more efficient (*)




PL/SQL is easier to learn but less efficient




PL/SQL is easier to learn and does not require an Oracle database or tool






Incorrect. Refer to Section 1 Lesson 2.




2. 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 (*)






Incorrect. Refer to Section 1 Lesson 2.




3. Which of the following statements about exception handling in PL/SQL is false?
Mark for Review
(1) Points


You can prepare for database exceptions by creating exception handlers.




You can prepare for application exceptions by creating exception handlers.




Exception handling code tells your program what to do when an error is
encountered.



Exception handling code can be grouped together in a PL/SQL block.




None of the above (*)






Incorrect. Refer to Section 1 Lesson 2.




4. SQL is a common access language for many types of databases, including Oracle.
True or False?
Mark for Review
(1) Points


True (*)




False






Incorrect. Refer to Section 1 Lesson 1.




5. Which of the following statements about PL/SQL and SQL is true?
Mark for Review
(1) Points


PL/SQL and SQL are both ANSI-compliant.




PL/SQL and SQL can be used with many types of databases, including Oracle.




PL/SQL and SQL are both Oracle proprietary programming languages.




PL/SQL allows basic program logic and control flow to be combined with SQL
statements. (*)





Incorrect. Refer to Section 1 Lesson 1.




6. The P in PL/SQL stands for:
Mark for Review
(1) Points


Processing




Procedural (*)




Primary




Proprietary






Correct




7. Errors are handled in the Exception part of the PL/SQL block. True or False?
Mark for Review
(1) Points


True (*)




False






Incorrect. Refer to Section 1 Lesson 3.




8. Every PL/SQL anonymous block must start with the keyword DECLARE. True or
False?
Mark for Review
(1) Points


True




False (*)






Correct




9. Which of the following tools can NOT be used to develop and test PL/SQL code?
Mark for Review
(1) Points


Oracle Jdeveloper




Oracle Application Express




Oracle JSQL (*)




Oracle iSQL*Plus






Incorrect. Refer to Section 1 Lesson 3.




10. Given below are the parts of a PL/SQL block:
1. END;
2. EXCEPTION
3. DECLARE
4. BEGIN
Arrange the parts in order.
Mark for Review
(1) Points


2,1,4,3




3,4,2,1 (*)




3,2,4,1




4,3,2,1






Correct



























Answer all questions in this section)


11. Which PL/SQL block type must return a value?
Mark for Review
(1) Points


Anonymous




Function (*)




Procedure






Correct




12. What kind of block is defined by the following PL/SQL code?
BEGIN
DBMS_OUTPUT.PUT_LINE('My first quiz');
END;
Mark for Review
(1) Points


procedure




subroutine




function




anonymous (*)






Incorrect. Refer to Section 1 Lesson 3.





Section 2
(Answer all questions in this section)


13. Which of the following is an example of using a case convention for good
programming practice?
Mark for Review
(1) Points


Assign variables by using functions.




Declare variables in the DECLARE section.




Declare data types in uppercase. (*)




Include an exception handler in every PL/SQL block.






Incorrect. Refer to Section 2 Lesson 7.




14. Which good programming practice guideline would make this code easier to read?
DECLARE
v_sal NUMBER(8,2);
BEGIN
SELECT salary INTO v_sal
FROM employees WHERE employee_id = 100;
UPDATE employees SET salary = v_sal;
END;
Mark for Review
(1) Points


Declaring variables using %TYPE




Indenting each level of code (*)




Using a consistent naming convention for variables




Avoiding implicit data type conversions






Correct




15. To comment a single line of code, use two dashes after the comment. True or
False?
Mark for Review
(1) Points


True




False (*)






Correct




16. When a variable is defined using the NOT NULL keywords, the variable must
contain a value. True or False?
Mark for Review
(1) Points


True (*)




False






Incorrect. Refer to Section 2 Lesson 1.




17. Variables can be used in the following ways in a PL/SQL block. (Choose two.)
Mark for Review
(1) Points

(Choose all correct answers)



To store data values. (*)




To rename tables and columns.




To refer to a single data value several times. (*)




To comment code.






Incorrect. Refer to Section 2 Lesson 1.




18. Variables can be assigned a value in both the Executable and Declaration sections
of a PL/SQL program. True or False?
Mark for Review
(1) Points


True (*)




False






Correct




19. Identify which of the following assignment statements are valid. (Choose three.)
Mark for Review
(1) Points

(Choose all correct answers)



v_last_name := Chandra;




v_blackout_date := '31-DEC-2006'; (*)




v_population := 333444; (*)




v_music_type := 'ROCK'; (*)






Incorrect. Refer to Section 2 Lesson 1.




20. What will be displayed when the following code is executed?
DECLARE
varA NUMBER := 12;
BEGIN
DECLARE
varB NUMBER := 8;
BEGIN
varA := varA + varB;
END;
DBMS_OUTPUT.PUT_LINE(varB);
END;
Mark for Review
(1) Points


8




12




Nothing, the block will fail with an error (*)




20




VarB






Incorrect. Refer to Section 2 Lesson 6.




21. When an
exception
occurs
within a
PL/SQL
block, the
remaining
statements
in the
executable
section of
the block
are
skipped.
True or
False?
Mark for Review
(1) Points


True (*)




False






Correct




22. An exception occurs within the inner block of two nested blocks. The inner
block does not have an EXCEPTION section. What always happens?
Mark for Review
(1) Points


Both blocks fail and an error message is displayed by the calling
environment



The exception is propagated to the outer block (*)




Oracle automatically tries to re-execute the inner block




The user's database session is automatically disconnected






Incorrect. Refer to Section 2 Lesson 6.




23. Examine the following code. At Line A, we want to assign a value of 22 to the
outer block's variable v_myvar. What code should we write at Line A?
<<outer_block>>
DECLARE
v_myvar NUMBER;
BEGIN
<<inner_block>>
DECLARE
v_myvar NUMBER := 15;
BEGIN
-- Line A
END;
END;
Mark for Review
(1) Points


outer_block.v_myvar := 22; (*)




v_myvar := 22;




<<outer_block>>.v_myvar := 22;




v_myvar(outer_block) := 22;




We cannot reference the outer block's variable because both variables
have the same name





Incorrect. Refer to Section 2 Lesson 6.




24. In the following code, Line A causes an exception. What value will be displayed
when the code is executed?
DECLARE
outer_var VARCHAR2(50) := 'My';
BEGIN
outer_var := outer_var || ' name';
DECLARE
inner_var NUMBER;
BEGIN
inner_var := 'Mehmet'; -- Line A
outer_var := outer_var || ' is';
END;
outer_var := outer_var || ' Zeynep';
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(outer_var);
END;
Mark for Review
(1) Points



My




My name (*)




My name is




My name is Zeynep






Correct




25. What is the data type of the variable V_DEPT_TABLE in the following
declaration?
DECLARE
TYPE dept_table_type IS TABLE OF departments%ROWTYPE INDEX BY
PLS_INTEGER; v_dept_table dept_table_type; ...
Mark for Review
(1) Points


Scalar




Composite (*)




LOB






Correct




26. ______ are meant to store large amounts of data.
Mark for Review
(1) Points


Variables




Scalar data types




LOBs (*)






Incorrect. Refer to Section 2 Lesson 3.




27. A movie is an example of which category of data type?
Mark for Review
(1) Points


Scalar




Composite




Reference




LOB (*)






Incorrect. Refer to Section 2 Lesson 3.




28. Which of the following are valid identifiers? (Choose two.)
Mark for Review
(1) Points

(Choose all correct answers)



Full Name




students_street_address (*)




v_code (*)




#hours




completion_%






Incorrect. Refer to Section 2 Lesson 2.




29. Delimiters are _____ that have special meaning to the Oracle database.
Mark for Review
(1) Points


identifiers




variables




symbols (*)






Incorrect. Refer to Section 2 Lesson 2.




30. Valid identifiers begin with a
Mark for Review
(1) Points


Number




Letter (*)




Special character






Correct


31. Which of
the
following
can be
assigned
to a
Boolean
variable?
1. Null
2. False
3. True
4. 0
Mark for Review
(1) Points


2 and 3




2, 3 and 4




1, 2 and 3 (*)




1, 2, 3 and 4






Incorrect. Refer to Section 2 Lesson 4.




32. A variable must have a value if NOT NULL is specified. True or False?
Mark for Review
(1) Points


True (*)




False






Incorrect. Refer to Section 2 Lesson 4.




33. If you are using the %TYPE attribute, you can avoid hard coding the:
Mark for Review
(1) Points


Data type (*)




Table name




Column name




Constraint






Incorrect. Refer to Section 2 Lesson 4.




34. Examine the following code. What is the final value of V_MYBOOL ?
DECLARE
v_mynumber NUMBER;
v_mybool BOOLEAN ;
BEGIN
v_mynumber := 6;
v_mybool := (v_mynumber BETWEEN 10 AND 20);
v_mybool := NOT (v_mybool);
END;
Mark for Review
(1) Points


True (*)




False






Incorrect. Refer to Section 2 Lesson 5.




35. The implicit data type conversion at Point A may not work correctly. Why not?
DECLARE
v_mydate DATE;
BEGIN
V_MYDATE := '29-Feb-2004'; -- Point A
END;
Mark for Review
(1) Points


There are only 28 days in February




Oracle cannot implicitly convert a character string to a date, even if the
string contains a valid date value



If the database language is not English, 'Feb' has no meaning. (*)




V_MYDATE has been entered in uppercase






Incorrect. Refer to Section 2 Lesson 5.




36. What is the output when the following program is executed?
set serveroutput on
DECLARE
a VARCHAR2(10) := '333';
b VARCHAR2(10) := '444';
c PLS_INTEGER;
d VARCHAR2(10);
BEGIN
c := TO_NUMBER(a) + TO_NUMBER(b);
d := a || b;
DBMS_OUTPUT.PUT_LINE(c);
DBMS_OUTPUT.PUT_LINE(d);
END;
Mark for Review
(1) Points



Nothing. The code will result in an error.




c=777 and d=333444 (*)




c=777 and d=777




c=333444 and d=777






Incorrect. Refer to Section 2 Lesson 5.




37. What is wrong with this assignment statement?
myvar := 'To be or not to be';

'That is the question';
Mark for Review
(1) Points


An assignment statement must be a single line of code




Nothing is wrong, the statement is fine




An assignment statement must have a single semicolon at the end (*)




"myvar" is not a valid name for a variable




Character literals should not be enclosed in quotes






Correct




38. Which of the following are valid assignment statements? (Choose two.)
Mark for Review
(1) Points

(Choose all correct answers)



v_string = 'Hello';




v_string := Hello;




v_number := 17 + 34; (*)




v_string := 'Hello'; (*)




v_date := 28-DEC-06;






Incorrect. Refer to Section 2 Lesson 5.




39. If today's date is 14th June 2007, which statement will correctly convert today's
date to the value: June 14, 2007 ?
Mark for Review
(1) Points


TO_CHAR(sysdate)




TO_DATE(sysdate)




TO_DATE(sysdate,'Month DD, YYYY')




TO_CHAR(sysdate, 'Month DD, YYYY') (*)






Incorrect. Refer to Section 2 Lesson 5.




40. Single row character functions are valid SQL functions in PL/SQL. True or False?
Mark for Review
(1) Points


True (*)




False






Incorrect. Refer to Section 2 Lesson 5.




Section 2
(Answer all questions in this section)


41. The DECODE function is available in PL/SQL procedural statements. True or False?
Mark for Review
(1) Points


True




False (*)






Correct





Section 3
(Answer all questions in this section)


42. Which rows will be deleted from the EMPLOYEES table when the following code is
executed?
DECLARE
salary employees.salary%TYPE := 12000;
BEGIN
DELETE FROM employees
WHERE salary > salary;
END;
Mark for Review
(1) Points


All rows whose SALARY column value is greater than 12000.




All rows in the table.




No rows. (*)




All rows whose SALARY column value is equal to 12000.






Incorrect. Refer to Section 3 Lesson 2.




43. Which one of these SQL statements can be directly included in a PL/SQL executable
block?
Mark for Review
(1) Points


SELECT last_name FROM employees
WHERE employee_id=100;



DESCRIBE employees;




UPDATE employees
SET last_name='Smith';
(*)



DROP TABLE employees;






Incorrect. Refer to Section 3 Lesson 2.




44. The following code will return the last name of the employee whose employee id is
equal to 100: True or False?
DECLARE
v_last_name employees.last_name%TYPE;
employee_id employees.employee_id%TYPE := 100;
BEGIN
Mark for Review
(1) Points
SELECT last_name INTO v_last_name
FROM employees
WHERE employee_id = employee_id;
END;


True




False (*)






Incorrect. Refer to Section 3 Lesson 2.




45. Given this first section of code:
DECLARE
v_result employees.salary%TYPE;
BEGIN
Which statement will always return exactly one value?
Mark for Review
(1) Points


SELECT salary
INTO v_result
FROM employees;



SELECT salary
INTO v_result
FROM employees
WHERE last_name ='Smith';



SELECT salary
INTO v_result
FROM employees
WHERE department_id = 80;



SELECT SUM(salary)
INTO v_result
FROM employees;
(*)





Incorrect. Refer to Section 3 Lesson 2.




46. You declare an implicit cursor in the DECLARE section of a PL/SQL block. True or
False?
Mark for Review
(1) Points


True




False (*)






Correct




47. Which SQL statement can NOT use an implicit cursor?
Mark for Review
(1) Points


A DELETE statement




An UPDATE statement




A SELECT statement that returns multiple rows (*)




A SELECT statement that returns one row






Incorrect. Refer to Section 3 Lesson 3.




48. 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


All employees get a 10% salary increase. (*)




No rows are modified because you did not specify "WHERE department_id=10"




A TOO_MANY_ROWS exception is raised.




An error message is displayed because you must use the INTO clause to hold the
new salary.





Incorrect. Refer to Section 3 Lesson 3.




49. The following anonymous block of code is run:
BEGIN
INSERT INTO countries (id, name)
VALUES ('XA', 'Xanadu');
INSERT INTO countries (id, name)
VALUES ('NV','Neverland');
COMMIT;
COMMIT;
ROLLBACK;
END;
What happens when the block of code finishes?
Mark for Review
(1) Points


You have nothing new; the last ROLLBACK undid the INSERTs.




You have the rows added twice; there are four new rows.




You have the two new rows added. (*)




You get an error; you cannot COMMIT twice in a row.






Incorrect. Refer to Section 3 Lesson 4.




50. How many DML statements can be included in a single transaction?
Mark for Review
(1) Points


Only one




None. A transaction cannot include DML statements.




A maximum of four DML statements




As many as needed (*)






Incorrect. Refer to Section 3 Lesson 4.

You might also like