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.
A Stored Procedure is a a. Sequence of SQL or PL/SQL statements to perform specific function. b. b. Stored in compiled form in the database. c. c. Can be called from all client environments. d. d. All of the above.
Which of the following is NOT VALID in PL/SQL ? a] Select ... Into b] Update c] Create d] Delete
What is the Result of the following 'VIK'||NULL||'RAM' ? a] Error b] VIK RAM c] VIKRAM d] NULL
 Declare a number := 5; b number := null; c number := 10; Begin if a > b AND a < c then a := c * a; end if; End; What will be the value of 'a' after execution ? a] 50 b] NULL c] 5 d] None of the above
Consider the following code snippet: how many times the loop will run? DECLARE a number(2) := 9; BEGIN WHILE a < 30 LOOP a := a + 3; END LOOP; END; A - 10 B - 8 C - 7 D - 9
- Which of the following is true about comments in PL/SQL? A - Comments are explanatory statements. B - PL/SQL supports both single-line and multi-line comments. C - The PL/SQL single-line comments start with the delimiter -- (double hyphen) and multi-line comments are enclosed by /* and */. D - All of the above.
DECLARE a number; PROCEDURE squareNum(x IN OUT number) IS BEGIN x := x * x; END; BEGIN a:= 5; squareNum(a); dbms_output.put_line(a); END; A - 5 B - 10 C - 25 D - 0
What will be the output of the following code snippet? DECLARE a number(3) := 100; b number(3) := 200; BEGIN IF( a = 100 ) THEN IF( b <> 200 ) THEN dbms_output.put_line(b); END IF; END IF; dbms_output.put_line(a); END; A - It has syntax error, so there will not be any output. B - 200 C - 200 100 D - 100
What will happen when the code is executed? DECLARE num number := 95; BEGIN dbms_output.put_line('num: ' || num1); DECLARE num number := 195; BEGIN dbms_output.put_line('num: ' || num1); END; END; A - It won’t execute, it has syntax error B - It will print num: 95 num: 195 C - It will print num: 95 num: 95 D - It will print num: 195 num: 195
Consider the following code snippet: how many times the loop will run? DECLARE a number(2) := 9; BEGIN WHILE a < 30 LOOP a := a + 3; END LOOP; END; A - 10 B - 8 C - 7 D - 9
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.
Which of the following is true about the execution section of a PL/SQL block?  A - It is enclosed between the keywords BEGIN and END.  B - It is a mandatory section.  C - It consists of the executable PL/SQL statements.  D - All of the above.
What is the output of the following code? DECLARE x number := 4; BEGIN LOOP dbms_output.put_line(x); x := x + 1; exit WHEN x > 5; END LOOP; dbms_output.put_line(x); END; A - 4 5 6 B - 4 5 C - 4 D - None of the above.
DECLARE num number; fn number; FUNCTION fx(x number) RETURN number IS f number; BEGIN IF x=0 THEN f := 1; ELSE f := x * fx(x-1); END IF; RETURN f; END; BEGIN num:= 5; Fn := fx(num); dbms_output.put_line(fn); END; A - 1 B - 5 C - 10 D - 125
Which of the following is the correct syntax for creating an explicit cursor?   A - CURSOR cursor_name IS select_statement;  B - CREATE CURSOR cursor_name IS select_statement;  C - CREATE CURSOR cursor_name AS select_statement;  D - CURSOR cursor_name AS select_statement;
What would be printed when the following code is executed? DECLARE x NUMBER; BEGIN x := 5; x := 10; dbms_output.put_line(-x); dbms_output.put_line(+x); x := -10; dbms_output.put_line(-x); dbms_output.put_line(+x); END; A -10 10 10 -10 B 10 -10 10-10 C -10 +10 +10 -10 D - 10 -10 -10 10
Which of the following statements is true about implicit cursors? A.Implicit cursors are used for SQL statements that are not named. B. Developers should use implicit cursors with great care. C. Implicit cursors are used in cursor for loops to handle data processing. D. Implicit cursors are no longer a feature in Oracle.
Select invalid variable types A. CHAR B. VARCHAR1 C. VARCHAR2 D. INTEGER E. NUMBER
 he || is is an example of what function SELECT last_name || ', ' || first_name || ' ' || middle_name FROM employees; A. Incantination B. Integration C. Continuation D. Concatenation E. None of the above
Select the best answer. Which listed attribute is an invalid attribute of an Explicit cursor. A. %NOTFOUND B. %FOUND C. %ROWCOUNT D. %ISOPEN E. None of the above. All of these are valid.
PL SQL Quiz | PL SQL Examples

PL SQL Quiz | PL SQL Examples

  • 2.
    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.
  • 3.
    A Stored Procedureis a a. Sequence of SQL or PL/SQL statements to perform specific function. b. b. Stored in compiled form in the database. c. c. Can be called from all client environments. d. d. All of the above.
  • 4.
    Which of thefollowing is NOT VALID in PL/SQL ? a] Select ... Into b] Update c] Create d] Delete
  • 5.
    What is theResult of the following 'VIK'||NULL||'RAM' ? a] Error b] VIK RAM c] VIKRAM d] NULL
  • 6.
     Declare a number:= 5; b number := null; c number := 10; Begin if a > b AND a < c then a := c * a; end if; End; What will be the value of 'a' after execution ? a] 50 b] NULL c] 5 d] None of the above
  • 7.
    Consider the followingcode snippet: how many times the loop will run? DECLARE a number(2) := 9; BEGIN WHILE a < 30 LOOP a := a + 3; END LOOP; END; A - 10 B - 8 C - 7 D - 9
  • 8.
    - Which ofthe following is true about comments in PL/SQL? A - Comments are explanatory statements. B - PL/SQL supports both single-line and multi-line comments. C - The PL/SQL single-line comments start with the delimiter -- (double hyphen) and multi-line comments are enclosed by /* and */. D - All of the above.
  • 9.
    DECLARE a number; PROCEDURE squareNum(x INOUT number) IS BEGIN x := x * x; END; BEGIN a:= 5; squareNum(a); dbms_output.put_line(a); END; A - 5 B - 10 C - 25 D - 0
  • 10.
    What will bethe output of the following code snippet? DECLARE a number(3) := 100; b number(3) := 200; BEGIN IF( a = 100 ) THEN IF( b <> 200 ) THEN dbms_output.put_line(b); END IF; END IF; dbms_output.put_line(a); END; A - It has syntax error, so there will not be any output. B - 200 C - 200 100 D - 100
  • 11.
    What will happenwhen the code is executed? DECLARE num number := 95; BEGIN dbms_output.put_line('num: ' || num1); DECLARE num number := 195; BEGIN dbms_output.put_line('num: ' || num1); END; END; A - It won’t execute, it has syntax error B - It will print num: 95 num: 195 C - It will print num: 95 num: 95 D - It will print num: 195 num: 195
  • 12.
    Consider the followingcode snippet: how many times the loop will run? DECLARE a number(2) := 9; BEGIN WHILE a < 30 LOOP a := a + 3; END LOOP; END; A - 10 B - 8 C - 7 D - 9
  • 13.
    CREATE OR REPLACEFUNCTION 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.
  • 14.
    Which of thefollowing is true about the execution section of a PL/SQL block?  A - It is enclosed between the keywords BEGIN and END.  B - It is a mandatory section.  C - It consists of the executable PL/SQL statements.  D - All of the above.
  • 15.
    What is theoutput of the following code? DECLARE x number := 4; BEGIN LOOP dbms_output.put_line(x); x := x + 1; exit WHEN x > 5; END LOOP; dbms_output.put_line(x); END; A - 4 5 6 B - 4 5 C - 4 D - None of the above.
  • 16.
    DECLARE num number; fn number; FUNCTIONfx(x number) RETURN number IS f number; BEGIN IF x=0 THEN f := 1; ELSE f := x * fx(x-1); END IF; RETURN f; END; BEGIN num:= 5; Fn := fx(num); dbms_output.put_line(fn); END; A - 1 B - 5 C - 10 D - 125
  • 17.
    Which of thefollowing is the correct syntax for creating an explicit cursor?   A - CURSOR cursor_name IS select_statement;  B - CREATE CURSOR cursor_name IS select_statement;  C - CREATE CURSOR cursor_name AS select_statement;  D - CURSOR cursor_name AS select_statement;
  • 18.
    What would beprinted when the following code is executed? DECLARE x NUMBER; BEGIN x := 5; x := 10; dbms_output.put_line(-x); dbms_output.put_line(+x); x := -10; dbms_output.put_line(-x); dbms_output.put_line(+x); END; A -10 10 10 -10 B 10 -10 10-10 C -10 +10 +10 -10 D - 10 -10 -10 10
  • 19.
    Which of thefollowing statements is true about implicit cursors? A.Implicit cursors are used for SQL statements that are not named. B. Developers should use implicit cursors with great care. C. Implicit cursors are used in cursor for loops to handle data processing. D. Implicit cursors are no longer a feature in Oracle.
  • 20.
    Select invalid variabletypes A. CHAR B. VARCHAR1 C. VARCHAR2 D. INTEGER E. NUMBER
  • 21.
     he ||is is an example of what function SELECT last_name || ', ' || first_name || ' ' || middle_name FROM employees; A. Incantination B. Integration C. Continuation D. Concatenation E. None of the above
  • 22.
    Select the bestanswer. Which listed attribute is an invalid attribute of an Explicit cursor. A. %NOTFOUND B. %FOUND C. %ROWCOUNT D. %ISOPEN E. None of the above. All of these are valid.

Editor's Notes