0

programming languages Online Quiz - 204

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

Component A dependent on another Component B can access all Operations defined in B

  1. True

  2. False


Correct Option: B

From external components or systems perspective, a component is a .

  1. White-box

  2. Black-box

  3. Grey-box

  4. None


Correct Option: B

When a Component is released to shared pool, Which of the following statements hold true.

  1. It becomes Obsolete

  2. It becomes Frozen

  3. It is still available for Modeling

  4. None of above


Correct Option: B

is the process for determining the suitability of a Component for use within the intended final system.

  1. Adaptation

  2. Assembly

  3. Qualification

  4. Maintenance


Correct Option: C

DesignCompModeler is ready with his Model changes and now wants to share them with Other Components in that workspace, to do this, run

  1. Generate Code

  2. Fetch New Shared Model

  3. Release to Shared pool

  4. Track Model changes


Correct Option: C

Select the correct statements

  1. Component can exist outside workspace

  2. Dependencies can be defined between Components

  3. Component and Class are same entities

  4. Component can have Interfaces


Correct Option: B,D

A trigger is…

  1. a special type of table

  2. a special type of store procedure, executed when certain event occurs

  3. a special type of view

  4. a dynamic procedure


Correct Option: B

The TRUNCATE TABLE…

  1. checks if the table has primary key specified

  2. Deletes the table

  3. deletes all rows from a table

  4. change the structure of the table


Correct Option: C

Functions for error trapping are contained in which section of a PL/SQL block?

  1. Header

  2. Declarative

  3. Executable

  4. Exception


Correct Option: D
Explanation:

To solve this question, the user needs to understand the structure of a PL/SQL block and the purpose of each section.

The PL/SQL block is divided into the following sections:

  1. Header: This section is optional and contains comments and declarations of global variables and cursors.

  2. Declarative: This section is optional and contains declarations of local variables, cursors, types, and subprograms.

  3. Executable: This section is mandatory and contains the code that performs the desired operations.

  4. Exception: This section is optional and contains handlers for exceptions that may be raised during the execution of the executable section.

The correct answer is:

D. Exception

Functions for error trapping are contained in the exception section of a PL/SQL block. This section contains handlers for exceptions that may occur during the execution of the executable section. These handlers allow the program to gracefully handle errors and continue executing, rather than crashing or terminating unexpectedly.

Select the VALID trigger type(s)?

  1. AFTER statement trigger

  2. INSERT row trigger

  3. DELETE row trigger

  4. All of the above


Correct Option: A

AI Explanation

To answer this question, you need to understand the different types of triggers in a database.

Option A) AFTER statement trigger - This option is valid because an AFTER statement trigger is a type of trigger that is fired after a SQL statement is executed.

Option B) INSERT row trigger - This option is not valid because there is no specific trigger type called "INSERT row trigger." However, there is a trigger type called "AFTER INSERT trigger," which is fired after a new row is inserted into a table.

Option C) DELETE row trigger - This option is not valid because there is no specific trigger type called "DELETE row trigger." However, there is a trigger type called "AFTER DELETE trigger," which is fired after a row is deleted from a table.

Option D) All of the above - This option is not valid because only option A (AFTER statement trigger) is a valid trigger type.

Therefore, the correct answer is option A.

PL/SQL raises an exception, in which TWO of the following cases:

  1. When a SELECT statement returns no rows

  2. When a SELECT statement returns more than one row

  3. When the datatypes of SELECT clause and INTO clause do not match

  4. When INTO statement is missing in the SELECT statement


Correct Option: A,B

In a PL/SQL block, a variable is declared as NUMBER without an initial value. What will its value be when it is first used in the executable section of the PL/SQL block?

  1. NULL

  2. 0

  3. Results in a compilation error

  4. An exception will be raised


Correct Option: A

Which of the following SQL functions can operate on any datatype?

  1. TO_CHAR

  2. LOWER

  3. LPAD

  4. MAX


Correct Option: D

AI Explanation

To answer this question, let's go through each option to understand which SQL functions can operate on any datatype:

Option A) TO_CHAR - This function is used to convert a value to a character datatype. It is typically used to convert numerical or date values to a character representation. However, it cannot operate on any datatype, as it requires a specific datatype as input.

Option B) LOWER - This function converts a string to lowercase. It can operate on string datatypes, but not on any datatype.

Option C) LPAD - This function is used to pad a string with a specific character to a specified length. It can operate on string datatypes, but not on any datatype.

Option D) MAX - This function returns the maximum value from a set of values. It can operate on any datatype, including numerical, string, and date datatypes. Therefore, the correct answer is D) MAX.

The correct answer is D) MAX. This option is correct because the MAX function can operate on any datatype.

Which section of a PL/SQL block would most likely contain a RAISE statement?

  1. Header

  2. Declarative

  3. Executable

  4. Exception


Correct Option: C,D

AI Explanation

To answer this question, we need to understand the structure of a PL/SQL block and the purpose of a RAISE statement.

A PL/SQL block is divided into four sections:

  1. Header: This section is optional and contains the declaration of variables, constants, and cursors.
  2. Declarative: This section is also optional and is used to define local subprograms, such as procedures and functions.
  3. Executable: This section is mandatory and contains the actual executable statements of the block.
  4. Exception: This section is optional and is used to handle exceptions that may occur during the execution of the block.

A RAISE statement is used to raise an exception manually. It allows you to specify the type of exception and an optional error message. When a RAISE statement is encountered, it transfers control to the exception section of the block.

Considering the purpose of the RAISE statement, it is most likely to be found in the Executable section or the Exception section of a PL/SQL block.

Therefore, the correct answer is C. Executable and D. Exception. These sections are the most likely places to find a RAISE statement in a PL/SQL block.

Which of the following statements gets the total value of the column 'Price' in the 'Sales' table?

  1. SELECT ADD(Price) FROM Sales

  2. SELECT SUM(Price) WHERE Sales

  3. SELECT TOTAL(Price) FROM Sales

  4. SELECT SUM(Price) FROM Sales


Correct Option: D
Explanation:

To solve this question, the user needs to know the correct SQL syntax for getting the total value of a column in a table. The correct SQL syntax for getting the total value of a column in a table is to use the SUM() function.

Now, let's go through each option and explain why it is right or wrong:

A. SELECT ADD(Price) FROM Sales: This option is incorrect because there is no ADD() function in SQL. The user should have used SUM() instead of ADD().

B. SELECT SUM(Price) WHERE Sales: This option is incorrect because the WHERE clause is incomplete. The correct SQL syntax would be to use the FROM keyword after the WHERE clause to specify the table from which to retrieve the data. Additionally, the correct SQL syntax for getting the total value of a column is to use the SUM() function, not the WHERE keyword.

C. SELECT TOTAL(Price) FROM Sales: This option is incorrect because there is no TOTAL() function in SQL. The user should have used SUM() instead of TOTAL().

D. SELECT SUM(Price) FROM Sales: This option is correct. The user has used the correct SQL syntax to get the total value of the 'Price' column in the 'Sales' table. The SUM() function is used to add up all the values in the 'Price' column and return the total value.

The Answer is: D

Which of the following SQL statements does count the rows in the 'Sales' table?

  1. SELECT COUNT(*) FROM Sales

  2. SELECT COUNT(*) IN Sales

  3. SELECT COUNTER(*) FROM Sales

  4. SELECT NUM() FROM Sales


Correct Option: A
Explanation:

To count the rows in a table, we use the COUNT() function in SQL. The correct answer is:

The Answer is: A. SELECT COUNT(*) FROM Sales

Explanation:

A. SELECT COUNT() FROM Sales: This option is correct because it uses the COUNT() function to count all the rows in the 'Sales' table. The () symbol means that we are counting all the rows.

B. SELECT COUNT(*) IN Sales: This option is incorrect because the syntax is not correct. The keyword IN cannot be used in this context.

C. SELECT COUNTER(*) FROM Sales: This option is incorrect because there is no such function as COUNTER() in SQL. The correct function name is COUNT().

D. SELECT NUM() FROM Sales: This option is incorrect because there is no such function as NUM() in SQL. We need to use the COUNT() function to count the rows in the table.

Therefore, option A is the correct answer.

Given the following code: public class OrtegorumFunction { public int computeDiscontinuous(int x) { int r = 1; r += X; if ((x > 4) && (x < 10)) { r += 2 * x; } else (x <= 4) { r += 3 * x; } else { r += 4 * x; } r += 5 * x; return r; } public static void main(String [] args) { OrtegorumFunction o = new OrtegorumFunction(); System.out.println("OF(11) is: " + o.computeDiscontinuous (11)); } } What is the result?

  1. OF(11) is: 45

  2. OF(11) is: 56

  3. OF(11) is: 89

  4. OF(11) is: 111

  5. Compilation fails

  6. An exception is thrown at runtime.


Correct Option: E

Given: 1. class Crivitch { 2. public static void main(String [] args) { 3. int x = 0; 4. // insert code here 5. do { } while (x++ < y); 6. System.out.println(x); 7. } 8. } Which, inserted at line 4, produces the output 12?

  1. int y = x;

  2. int y = 10;

  3. int y = 11;

  4. int y = 12;

  5. int y = 13;

  6. None of the above will allow compilation to succeed


Correct Option: C

AI Explanation

To determine the code that, when inserted at line 4, produces the output 12, let's analyze the given code:

  1. The code starts with a class declaration Crivitch and the main method.
  2. At line 3, the variable x is initialized to 0.
  3. At line 5, there is a do-while loop that continues until x++ is no longer less than y.
  4. At line 6, the value of x is printed.
  5. The code ends with the closing curly braces for the main method and the Crivitch class.

To produce the output 12, we need to find the value of y that satisfies the condition x++ &lt; y until x becomes 12.

Let's go through each option:

Option A) int y = x; This option assigns the value of x to y. Since x is initially 0, y will also be 0. The loop condition x++ &lt; y will never be true, so the loop will not execute. Therefore, this option is incorrect.

Option B) int y = 10; This option assigns the value of 10 to y. Since the loop condition x++ &lt; y starts with x as 0, the loop will execute 11 times (from x = 0 to x = 10). After the loop, x will be incremented to 11 and printed. Therefore, this option is incorrect.

Option C) int y = 11; This option assigns the value of 11 to y. Since the loop condition x++ &lt; y starts with x as 0, the loop will execute 12 times (from x = 0 to x = 11). After the loop, x will be incremented to 12 and printed. Therefore, this option is correct.

Option D) int y = 12; This option assigns the value of 12 to y. Since the loop condition x++ &lt; y starts with x as 0, the loop will execute 13 times (from x = 0 to x = 12). After the loop, x will be incremented to 13 and printed. Therefore, this option is incorrect.

Option E) int y = 13; This option assigns the value of 13 to y. Since the loop condition x++ &lt; y starts with x as 0, the loop will execute 14 times (from x = 0 to x = 13). After the loop, x will be incremented to 14 and printed. Therefore, this option is incorrect.

Option F) None of the above will allow compilation to succeed. This option is incorrect because options B, C, D, and E would all allow compilation to succeed.

Therefore, the correct answer is option C) int y = 11. This option will produce the output 12.

Given: class Plane { static String s = "-"; public static void main(String[] args) { new Plane().s1() ; System.out.println(s); } void sl() { try { s2(); catch (Exception e) { s += "c"; } } void s2() throws Exception { s3(); s += "2"; s3(); s += "2b"; } void s3() throws Exception { throw new Exception(); } } What is the result?

  1. -

  2. -c

  3. -c2

  4. -2c

  5. -c22b

  6. -2c2b


Correct Option: B
Explanation:

To solve this question, we need to trace the execution of the code and see how the value of the variable s changes.

Starting with the main method, it creates a new instance of the Plane class and calls its method s1().

In the s1() method, it calls the method sl().

In the sl() method, it calls the method s2(). Since s2() throws an exception, execution of the sl() method is transferred to the catch block. Here, it appends "c" to the value of s.

Control is then transferred back to the s1() method, which then returns to the main method. Finally, the value of s is printed to the console, which is "-c" since the catch block was executed.

Therefore, the answer is: B. -c

- Hide questions