Computer Knowledge

Programming Fundamentals

2,611 Questions

Programming fundamentals form the core logic of software development and computer science. This includes variable declarations, pointer assignments, loop iterations, and exception handling. These technical topics are regularly tested in computer knowledge and IT officer competitive examinations.

Variables and arraysPointer assignmentsLoop iterationsException handling blocksCompile time errorsFunction references

Programming Fundamentals Questions

Multiple choice
  1. Procedure can be called from SQL prompt, while function cannot be called from SQL prompt.

  2. Function can return a value, while procedure cannot return any value.

  3. Functions can have arguments, while procedure cannot have arguments.

  4. Function can call procedures while procedure cannot call functions.

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The difference between a function and procedure is that a function can return a value to its calling function while a procedure cannot return a value. Function returns a value using the 'return' keyword. A function cannot return more than one value.

Multiple choice
  1. Declare

  2. Begin

  3. Return

  4. Exception

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The declaration section of a PL/SQL program is used to contain all variable declarations. While using a function, the declare keyword is replaced by 'is' keyword. All the variables are declared inside the 'is' keyword. For example, CREATE OR REPLACE FUNCTION myfunc  RETURN VARCHAR(20); IS sname VARCHAR(20); BEGIN SELECT studname INTO sname FROM students WHERE rollno = 1; RETURN sname; END;

Multiple choice
  1. The mode of a parameter can be both IN and OUT.

  2. A cursor parameter can be assigned a default value.

  3. The scope of the cursor parameter is local to the cursor.

  4. We can only specify the datatype of the parameter, not its length.

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Parameterized cursors are static cursors that can accept passed-in parameter values when they are opened. The mode of parameter passed to a cursor can only be IN. The syntax for opening a parameterized cursor is open cursor_name(value)

Example: open mycursor(1000); where 1000 is the parameter value

Multiple choice
  1. There is no error and program will execute normally.

  2. Preprocessor directives are not used in the program.

  3. A function cannot be declared above main.

  4. Return statement should not be used with conditional operators.

  5. None of the above

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

return keyword cannot be used with conditional operator or with ternary operator.