PL/SQL Online Quiz


Advertisements


Following quiz provides Multiple Choice Questions (MCQs) related to PL/SQL. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Questions and Answers

Q 2 - To get the server output result and display it into the screen, you need to write −

A - set serveroutput on

B - set server output on

C - set dbmsoutput on

D - set dbms output on

Answer : A

Q 3 - Which of the following is true about the following code snippet?

DECLARE
   a number(3) := 100;
BEGIN
   IF (a = 50 ) THEN
      dbms_output.put_line('Value of a is 10' );
   ELSEIF ( a = 75 ) THEN
      dbms_output.put_line('Value of a is 20' );
   ELSE
       dbms_output.put_line('None of the values is matching');
   END IF;
   dbms_output.put_line('Exact value of a is: '|| a ); 
END;

A - It has syntax error.

B - It will print 'None of the values is matching'.

C - It will print

None of the values is matching

Exact value of a is: 100

D - None of the above.

Answer : A

Explanation

the ELSIF statement is wrongly written as ELSEIF

Q 5 - What is wrong in the following code snippet?

CREATE OR REPLACE FUNCTION totalCustomers
total number(2) := 0;
BEGIN
   SELECT count(*) into total
   FROM customers;
   RETURN total;
END;

A - It doesn’t have the RETURN clause in function declaration.

B - The RETURN statement is wrong.

C - Function definition should not use the IS keyword

D - Nothing wrong.

Answer : A

Explanation

The correct code should be

CREATE OR REPLACE FUNCTION totalCustomers
RETURN number IS
   total number(2) := 0;
BEGIN
   SELECT count(*) into total
   FROM customers;
   
   RETURN total;
END;

Q 6 - Which of the following is not among the types of PL/SQL records?

A - Table-based

B - View-based

C - Cursor-based records

D - User-defined records

Answer : B

Q 7 - Observe the syntax given below −

CREATE [OR REPLACE ] TRIGGER trigger_name 
{BEFORE | AFTER | INSTEAD OF } 
{INSERT [OR] | UPDATE [OR] | DELETE} 
[OF col_name] 
ON table_name 
[REFERENCING OLD AS o NEW AS n] 
[FOR EACH ROW] 
WHEN (condition)  
DECLARE
   Declaration-statements
BEGIN 
   Executable-statements
EXCEPTION
   Exception-handling-statements
END;

The {INSERT [OR] | UPDATE [OR] | DELETE} clause specifies a

A - DDL operation.

B - DML operation.

C - None of the above.

D - Both of the above.

Answer : B

Q 8 - All objects placed in a package specification are called

A - Public objects.

B - Private objects.

C - None of the above.

D - Both of the above.

Answer : A


plsql_questions_answers.htm

Advertisements