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

vi is the only text editor available in linux?

  1. True

  2. False


Correct Option: A

It is possible to redirect the output of a process to more than one source

  1. True

  2. False


Correct Option: A

tar can be used to write on to floppy disks

  1. True

  2. False


Correct Option: A

if statement needs to end with end if

  1. True

  2. False


Correct Option: B

du command displays the file system usage for the entire file system

  1. True

  2. False


Correct Option: B

Normal users can kill init process

  1. True

  2. False


Correct Option: B

top command can be used to control processes

  1. True

  2. False


Correct Option: B

Shell functions are self-contained and cannot be accessed from outside the function

  1. True

  2. False


Correct Option: B

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.

Which two statements are true? (Choose two)

  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

AI Explanation

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

Option A) A function must return a value - This option is correct because a function is a named PL/SQL block that returns a value. It is designed to perform a specific task and return a value to the caller.

Option B) A procedure must return a value - This option is incorrect because a procedure is a named PL/SQL block that performs a specific task, but it does not have to return a value. Procedures are commonly used to perform actions or modify data without returning a value.

Option C) A function executes a PL/SQL statement - This option is incorrect because a function is not specifically designed to execute PL/SQL statements. It is designed to perform a specific task and return a value.

Option D) A function is invoked as part of an expression - This option is correct because a function can be invoked as part of an expression. For example, you can use a function to calculate a value and assign it to a variable or use it in a calculation.

Option E) A procedure must have a return data type specified in its declaration - This option is incorrect because a procedure does not require a return data type to be specified in its declaration. Procedures are not designed to return a value, so they do not require a return data type.

The correct answers are A and D. A function must return a value, and a function can be invoked as part of an expression.

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

Which two statements about the overloading feature of packages are true? (Choose two)

  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

AI Explanation

To answer this question, we need to understand the concept of overloading in packages.

Option A) Only local or packaged subprograms can be overloaded. This statement is true. Overloading can only be applied to subprograms within a package or to local subprograms.

Option B) Overloading allows different functions with the same name that differ only in their return types. This statement is false. Overloading does not consider the return type of the function. It only considers the number, type, and order of the parameters.

Option C) Overloading allows different subprograms with the same number, type, and order of the parameters. This statement is false. Overloading allows different subprograms with the same name but different in either the number or type or order of the parameters.

Option D) Overloading allows different subprograms with the same name and same number or type of the parameters. This statement is false. Overloading allows different subprograms with the same name but with different numbers or types or orders of parameters.

Option E) Overloading allows different subprograms with the same name but different in either number or type or order of the parameter. This statement is true. Overloading allows different subprograms within a package or local subprograms with the same name but different numbers or types or orders of parameters.

Therefore, the correct statements about the overloading feature of packages are Option A) and Option 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
  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.

Which statements about JDBC are true? (2 answers)

  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

AI Explanation

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

Option A) JDBC is an API to connect to relational-, object- and XML data sources. This statement is incorrect. JDBC is primarily used for connecting to relational databases, not object or XML data sources. For connecting to object or XML data sources, other APIs like JPA (Java Persistence API) or JAXB (Java Architecture for XML Binding) are typically used.

Option B) JDBC stands for Java DataBase Connectivity. This statement is correct. JDBC stands for Java DataBase Connectivity. It is a Java API that provides a standard way to connect to and interact with relational databases.

Option C) JDBC is an API to access relational databases, spreadsheets and flat files. This statement is correct. JDBC can be used to access relational databases, spreadsheets, and flat files. It provides a set of classes and interfaces that enable Java programs to interact with these data sources using SQL queries.

Option D) JDBC is an API to bridge the object-relational mismatch between OO programs and relational. This statement is incorrect. While JDBC allows Java programs to interact with relational databases, it does not specifically address the object-relational mismatch. Object-relational mapping frameworks like Hibernate or JPA are designed to bridge this mismatch.

The correct answers are B) JDBC stands for Java DataBase Connectivity and C) JDBC is an API to access relational databases, spreadsheets and flat files.

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.

Which type of driver provides JDBC access via one or more ODBC drivers?

  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

AI Explanation

To answer this question, you need to understand the different types of JDBC drivers and their characteristics.

Option A) (a) Type 1 driver - This option is incorrect because a Type 1 driver does not provide JDBC access via one or more ODBC drivers. Type 1 drivers are known as JDBC-ODBC Bridge drivers and they use the ODBC API to connect to the database.

Option B) (b) Type 2 driver - This option is incorrect because a Type 2 driver does not provide JDBC access via one or more ODBC drivers. Type 2 drivers are known as Native-API partly Java drivers and they use the database-specific native API to connect to the database.

Option C) (c) Type 3 driver - This option is incorrect because a Type 3 driver does not provide JDBC access via one or more ODBC drivers. Type 3 drivers are known as Network Protocol drivers and they use a middle-tier server to communicate with the database.

Option D) (d) Type 4 driver - This option is correct because a Type 4 driver provides JDBC access via one or more ODBC drivers. Type 4 drivers are known as Native-Protocol Pure Java drivers and they directly communicate with the database using the database-specific network protocol, without the need for any additional software.

The correct answer is D) (d) Type 4 driver. This option is correct because a Type 4 driver provides JDBC access without the need for ODBC drivers.

Which type of driver converts JDBC calls into the network protocol used by the database management system directly?

  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: D
- Hide questions