Tag: programming languages

Questions Related to programming languages

What can be implemented to reuse a cursor definition in PL/SQL?

  1. Cursor FOR loop

  2. FETCH statement

  3. %ISOPEN attribute

  4. Parameters


Correct Option: D

What command can you use to test a named PL/SQL block for compilation?

  1. ANALYZE_SCHEMA

  2. CREATE OR REPLACE

  3. SHOW ERRORS

  4. FORMAT_ERROR_STACK


Correct Option: B

In CPP program if the function is defined in the same program file before it is called, a separate prototype is required.

  1. True

  2. False


Correct Option: B

Which of the following is an error in calling the function? void func( int i = 5, double d = 1.234 );

  1. func( 9, 5.67 )

  2. func( 4 )

  3. func()

  4. func( ,4 )


Correct Option: D

Which of the following can be used to modify the value of a variable?

  1. Pointer

  2. References

  3. Both

  4. None of the above


Correct Option: A

A const pointer cannot be assigned to an ordinary pointer.

  1. True

  2. False


Correct Option: A

Carl, a database user, creates and executes the following SQL statement: CREATE SYNONYM employee FOR stanley.employee; What statements below are true?

  1. Only Carl can access the EMPLOYEE synonym.

  2. The EMPLOYEE synonym is a public synonym.

  3. The synonym name cannot be the same as the object name.

  4. Stanley can access the EMPLOYEE synonym.

  5. The synonym can be accessed remotely.

  6. The EMPLOYEE synonym is a private synonym.


Correct Option: D,F

Which of the following SQL statements will not execute successfully? (Choose all that apply)

  1. SELECT lname, jobid, sal, sal+500 FROM emp;

  2. SELECT lname, jobid, sal FROM emp (sal + 500);

  3. SELECT lname, jobid, sal, sal + 500 “Bonus” FROM emp;

  4. SELECT lname, jobid, sal, sal + 500 bonus FROM emp

  5. SELECT lname || to_char(sal+500) “Employee Bonus” FROM emp;

  6. SELECT lname, sal + 500 Employee Bonus FROM emp;


Correct Option: B,D,F

AI Explanation

To answer this question, we need to analyze each SQL statement and determine whether it will execute successfully or not.

A. SELECT lname, jobid, sal, sal+500 FROM emp; This statement will execute successfully because it selects the lname, jobid, sal columns from the emp table and performs the addition of sal and 500.

B. SELECT lname, jobid, sal FROM emp (sal + 500); This statement will not execute successfully because there is a syntax error. The correct syntax to perform calculations on columns is to use the SELECT statement and specify the operation directly on the column, as shown in option A.

C. SELECT lname, jobid, sal, sal + 500 "Bonus" FROM emp; This statement will execute successfully because it selects the lname, jobid, sal columns from the emp table and performs the addition of sal and 500. It also assigns the alias "Bonus" to the calculated column.

D. SELECT lname, jobid, sal, sal + 500 bonus FROM emp; This statement will not execute successfully because there is a syntax error. The column name "bonus" is not enclosed in quotes or square brackets. To include special characters or spaces in column names, they should be enclosed in quotes or square brackets.

E. SELECT lname || to_char(sal+500) "Employee Bonus" FROM emp; This statement will execute successfully because it concatenates the lname column with the result of sal+500. The to_char function is used to convert the calculated value to a character data type. It also assigns the alias "Employee Bonus" to the calculated column.

F. SELECT lname, sal + 500 Employee Bonus FROM emp; This statement will not execute successfully because there is a syntax error. The column name "Employee Bonus" should be enclosed in quotes or square brackets.

Therefore, the SQL statements that will not execute successfully are B, D, and F.

You run the following SQL statement: SELECT a.lname, a.location, b.dname, b.hiredate FROM emp a, emp b WHERE a.empid=b.empid; Which options are correct? (Choose all that apply)

  1. This is an equijoin.

  2. This is a self join.

  3. Line 2 will return an error.

  4. Line 3 will return an error.

  5. The statement will execute successfully.


Correct Option: B,E