0

programming languages Online Quiz - 330

Description: programming languages Online Quiz - 330
Number of Questions: 20
Created by:
Tags: programming languages
Attempted 0/20 Correct 0 Score 0

Under which two circumstances do you design database triggers? (Choose two)

  1. a) To duplicate the functionality of other triggers.

  2. b) To replicate built-in constraints in the Oracle server such as primary key and foreign key.

  3. c) To guarantee that when a specific operation is performed, related actions are performed.

  4. d) For centralized, global operations that should be fired for the triggering statement, regardless of which user or application issues the statement.


Correct Option: C,D

AI Explanation

To answer this question, you need to understand the purpose and functionality of database triggers. Let's go through each option to understand why it is correct or incorrect:

Option A) To duplicate the functionality of other triggers - This option is incorrect. Triggers are not designed to duplicate the functionality of other triggers. Instead, triggers are used to perform specific actions when certain events occur in the database.

Option B) To replicate built-in constraints in the Oracle server such as primary key and foreign key - This option is incorrect. Built-in constraints such as primary key and foreign key are not replicated using triggers. Constraints are separate database objects that enforce data integrity rules.

Option C) To guarantee that when a specific operation is performed, related actions are performed - This option is correct. One of the main purposes of database triggers is to ensure that when a specific operation (such as an insert, update, or delete) is performed on a table, related actions are automatically performed. These related actions can include updating data in other tables, sending notifications, or performing calculations.

Option D) For centralized, global operations that should be fired for the triggering statement, regardless of which user or application issues the statement - This option is correct. Database triggers can be used to perform centralized, global operations that should be executed whenever a specific triggering statement is issued, regardless of the user or application that issues the statement. This allows for consistent and standardized behavior across the database.

The correct answer is C and D. These options correctly describe the circumstances under which database triggers are designed.

  1. a) A function must return a value.

  2. b) A procedure must return a value.

  3. c) A function executes a PL/SQL statement.

  4. d) A function is invoked as part of an expression.

  5. e) A procedure must have a return data type specify in its declaration.


Correct Option: A,D

All users currently have the INSERT privileges on the PLAYER table. You want only your users to insert into this table using the ADD_PLAYER procedure. Which two actions must you take? (Choose two)

  1. a) GRANT SELECT ON ADD_PLAYER TO PUBLIC;

  2. b) GRANT EXECUTE ON ADD_PLAYER TO PUBLIC;

  3. c) GRANT INSERT ON PLAYER TO PUBLIC;

  4. d) GRANT EXECUTE, INSERT ON ADD_PLAYER TO PUBLIC;

  5. e) REVOKE INSERT ON PLAYER FROM PUBLIC;


Correct Option: B,E
  1. a) Only local or packaged sub programs can be overloaded.

  2. b) Overloading allows different functions with the same name that differ only in their return types.

  3. c) Overloading allows different subprograms with the same number, type and order of the parameter.

  4. d) Overloading allows different subprograms with the same name and same number or type of the parameters.

  5. e) Overloading allows different subprograms with the same name but different in either number or type or order of parameter.


Correct Option: A,E
  1. a) Packages can be nested.

  2. b) You can pass parameters to packages.

  3. c) A package is loaded into memory each time it is invoked.

  4. d) The contents of packages can be shared by many applications.

  5. e) You can achieve information hiding by making package constructs private.


Correct Option: D,E

Which two program declarations are correct for a stored program unit? (Choose two)

  1. a) CREATE OR REPLACE FUNCTION tax_amt (p_id NUMBER) RETURN NUMBER

  2. b) CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER) RETURN NUMBER

  3. c) CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER, p_amount OUT NUMBER)

  4. d) CREATE OR REPLACE FUNCTION tax_amt (p_id NUMBER) RETURN NUMBER(10,2)

  5. e) CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER, p_amount OUT NUMBER(10, 2))


Correct Option: A,C
Explanation:

To answer this question, you need to understand the difference between functions and procedures in Oracle SQL. A function is a stored program unit that returns a single value, while a procedure is a stored program unit that can perform multiple actions and return multiple values. Let's go through each option to understand why it is correct or incorrect:

Option A) CREATE OR REPLACE FUNCTION tax_amt (p_id NUMBER) RETURN NUMBER - This option is correct because it is a valid syntax for declaring a function that takes a number parameter and returns a number value.

Option B) CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER) RETURN NUMBER - This option is incorrect because a procedure cannot use the RETURN keyword to specify the return type. A procedure can only use the OUT or IN OUT parameters to return values.

Option C) CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER, p_amount OUT NUMBER) - This option is correct because it is a valid syntax for declaring a procedure that takes a number parameter and returns another number value using the OUT parameter.

Option D) CREATE OR REPLACE FUNCTION tax_amt (p_id NUMBER) RETURN NUMBER(10,2) - This option is incorrect because a function cannot use the precision and scale modifiers to specify the return type. A function can only use the data type name to specify the return type.

Option E) CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER, p_amount OUT NUMBER(10, 2)) - This option is incorrect because a procedure cannot use the precision and scale modifiers to specify the OUT parameter type. A procedure can only use the data type name to specify the OUT parameter type.

The correct answer is A and C. These options are correct because they are valid syntaxes for declaring a function and a procedure respectively.

Examine this procedure: CREATE OR REPLACE PROCEDURE UPD_BAT_STAT (V_ID IN NUMBER DEFAULT 10, V_AB IN NUMBER DEFAULT 4) IS BEGIN UPDATE PLAYER_BAT_STAT SET AT_BATS = AT_BATS + V_AB WHERE PLAYER_ID = V_ID; COMMIT; END; Which two statements will successfully invoke this procedure in SQL *Plus? (Choose two)

  1. a) EXECUTE UPD_BAT_STAT;

  2. b) EXECUTE UPD_BAT_STAT(V_AB=>10, V_ID=>31);

  3. c) EXECUTE UPD_BAT_STAT(31, 'FOUR', 'TWO');

  4. d) UPD_BAT_STAT(V_AB=>10, V_ID=>31);

  5. e) RUN UPD_BAT_STAT;


Correct Option: A,B

Which three are true regarding error propagation? (Choose three)

  1. a) An exception cannot propagate across remote procedure calls.

  2. b) An exception raised inside a declaration immediately propagates to the current block.

  3. c) The use of the RAISE; statement in an exception handler reprises the current exception

  4. d) An exception raised inside an exception handler immediately propagates to the enclosing block.


Correct Option: A,C,D

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) An exception cannot propagate across remote procedure calls. - This option is true. When a remote procedure call is made, any exceptions raised within the remote procedure will not propagate back to the calling procedure.

Option B) An exception raised inside a declaration immediately propagates to the current block. - This option is incorrect. Exceptions raised inside a declaration do not immediately propagate to the current block. They need to be explicitly handled or propagated using appropriate exception handling mechanisms.

Option C) The use of the RAISE; statement in an exception handler reprises the current exception. - This option is true. The RAISE statement in an exception handler can be used to re-raise the current exception, allowing it to propagate to higher-level exception handlers or enclosing blocks.

Option D) An exception raised inside an exception handler immediately propagates to the enclosing block. - This option is true. When an exception is raised inside an exception handler, it immediately propagates to the enclosing block, allowing it to be handled or propagated further.

Based on the explanations above, the correct options are A, C, and D.

  1. [_] [a] JDBC is an API to connect to relational-, object- and XML data sources

  2. [_] [b] JDBC stands for Java DataBase Connectivity

  3. [_] [c] JDBC is an API to access relational databases, spreadsheets and flat files

  4. [_] [d] JDBC is an API to bridge the object-relational mismatch between OO programs and relational


Correct Option: B,C

Which packages contain the JDBC classes?

  1. O (a) java.jdbc and javax.jdbc

  2. O (b) java.jdbc and java.jdbc.sql

  3. O (c) java.sql and javax.sql

  4. O (d) java.rdb and javax.rdb


Correct Option: C
Explanation:

To answer this question, the user needs to have knowledge about the JDBC (Java Database Connectivity) API and its packages.

Option A: This option is incorrect. There is no package called javax.jdbc in the JDBC API.

Option B: This option is also incorrect. There is no package called java.jdbc.sql in the JDBC API.

Option C: This option is correct. The JDBC API contains two key packages: java.sql and javax.sql.

Option D: This option is incorrect. There is no package called java.rdb or javax.rdb in the JDBC API.

Therefore, the correct answer is:

The Answer is: C. java.sql and javax.sql.

  1. O (a) Type 1 driver

  2. O (b) Type 2 driver

  3. O (c) Type 3 driver

  4. O (d) Type 4 driver


Correct Option: A
- Hide questions