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 technology databases
  1. True

  2. False

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

The statement in the question is false. In PL/SQL, a function MUST return exactly one value to its calling environment, while a procedure returns zero or more values (through OUT parameters). The question claims the opposite - that functions return zero or more and procedures return one value. Therefore, the correct answer is False (option B). Functions are designed to compute and return a single value, whereas procedures are designed to perform actions and can optionally return values through output parameters.

Multiple choice technology databases
  1. The package itself cannot be called, parameterized, or nested.

  2. The format of a package is similar to that of a subprogram.

  3. The contents can be shared by many applications once written.

  4. None of the above.

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

This is a trick question - all three statements A, B, and C about packages are actually TRUE. Statement A is true - packages cannot be called, parameterized, or nested like subprograms can. Statement B is true - packages do have a format similar to subprograms with specification and body. Statement C is true - packages are designed for code sharing. Since the question asks 'which is false' and none of A, B, or C are false, the correct answer is D (None of the above).

Multiple choice technology databases
  1. Local variables.

  2. Arguments.

  3. Boolean variables.

  4. Substitution variables.

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

Arguments (parameters) are the interface between a procedure/function and its calling environment. IN arguments pass values INTO the procedure. OUT arguments pass values BACK to the caller. IN OUT does both. Local variables are internal to the procedure. Boolean variables are just a data type. Substitution variables are SQL*Plus interaction tools, not PL/SQL constructs.

Multiple choice technology databases
  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.

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

Functions MUST return a value and are invoked within expressions (like SELECT or assignments). Procedures do NOT return values - they perform actions. Options B and E are incorrect because procedures don't require return values. Option C is vague - both functions and procedures execute PL/SQL.

Multiple choice technology databases
  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.

Reveal answer Fill a bubble to check yourself
A,C,D Correct answer
Explanation

Exceptions cannot propagate across RPC boundaries without serialization. An exception raised in a declaration propagates to the enclosing block, not the current block. The RAISE statement without an exception name reraises the current exception, and exceptions in handlers propagate to the enclosing block.

Multiple choice technology programming languages
  1. (a) Basis

  2. (b) Copy

  3. (c) Replace

  4. (d) All of the above

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

To understand which statement requires the LIB compiler option, one must know what the LIB compiler option does. The LIB compiler option specifies the name of the library file to be used during the linking phase of the build process. The library file contains precompiled object code that can be linked to the program being built.

Now, let's go through each option and determine whether it requires the LIB compiler option or not:

A. (a) Basis: This statement does not require the LIB compiler option because it does not involve linking precompiled object code from a library file.

B. (b) Copy: This statement does not require the LIB compiler option because it does not involve linking precompiled object code from a library file.

C. (c) Replace: This statement requires the LIB compiler option because it involves linking precompiled object code from a library file. The library file specified in the LIB option will be used during the linking phase of the build process.

D. (d) All of the above: Since option C requires the LIB compiler option, the correct answer is D, i.e., all of the above.

Therefore, the answer is: D.

Multiple choice technology programming languages
  1. True

  2. False

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

To answer this question, the user needs to know about the concept of passing arguments between programs or functions.

The statement is true. If you pass fewer arguments than the number of data-names in the called program's identifier list, then the called program will not have enough information to complete its task, which can cause errors.

On the other hand, if you pass more arguments than the number of data-names in the identifier list, then some of the values will not have a place to go, which can also cause errors.

Therefore, the correct answer is:

The Answer is: A. True

Multiple choice technology programming languages
  1. (a) By Reference

  2. (b) By Content

  3. (c) By Value

  4. (d) All of the above

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

To pass data between programs, there are different ways, and each method has its own pros and cons. The user needs to know the different ways to pass data between programs.

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

A. (a) By Reference: This option is one of the ways to pass data between programs. In this method, the address of the data (a pointer) is passed to the receiving program, and the receiving program accesses the data through the pointer. This method is efficient in terms of memory usage, but it requires extra care to ensure that the data remains valid and unchanged during the transfer.

B. (b) By Content: This option is not a common way to pass data between programs. In this method, the data is encapsulated in a message or a file, and the message or file is passed to the receiving program. This method can be used when the data is too large to pass as a parameter, or when the data needs to be persisted.

C. (c) By Value: This option is another way to pass data between programs. In this method, a copy of the data is passed to the receiving program. This method is simple and easy to implement, but it can be inefficient when dealing with large data sets.

D. (d) All of the above: This option is correct as all the three options mentioned above - by reference, by content, and by value - are valid ways to pass data between programs, and each method has its own advantages and disadvantages. The choice of the method depends on the specific requirements of the programs involved in the data exchange.

The Answer is: D

Multiple choice technology programming languages
  1. (a) CALL . . . BY CONTENT literal

  2. (b) CALL . . . BY CONTENT identifier

  3. (c) CALL . . . BY CONTENT ADDRESS OF identifier

  4. (d) CALL . . . BY CONTENT ADDRESS OF identifier

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

To solve this question, the user needs to know the different ways to pass parameters to a subprogram in programming languages.

The options in the question are using the "CALL" statement to pass a copy of the identifier to a subprogram. The CALL statement is used to transfer control to a subprogram (procedure or function) and pass arguments, if any.

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

A. (a) CALL . . . BY CONTENT literal: This option is incorrect because it passes a literal value to the subprogram, not an identifier. The "BY CONTENT" phrase specifies that the value is passed by value, which means a copy of the value is passed to the subprogram.

B. (b) CALL . . . BY CONTENT identifier: This option is correct because it passes a copy of the identifier (variable name) to the subprogram. The "BY CONTENT" phrase specifies that the value of the identifier is passed by value, which means a copy of the value is passed to the subprogram.

C. (c) CALL . . . BY CONTENT ADDRESS OF identifier: This option is incorrect because it passes the address of the identifier to the subprogram, not a copy of the value. The "BY CONTENT ADDRESS OF" phrase specifies that the address of the identifier is passed by value, which means a copy of the address is passed to the subprogram.

D. (d) CALL . . . BY CONTENT ADDRESS OF identifier: This option is incorrect because it is the same as option C, which passes the address of the identifier to the subprogram.

Therefore, the correct answer is:

The Answer is: B. (b) CALL . . . BY CONTENT identifier

Multiple choice technology programming languages
  1. (a) CALL . . . RETURNING

  2. (b) CALL . . . RECURRING

  3. (c) CALL . . . RECURSIVE

  4. (d) CALL . . . REFERRING

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

In COBOL, when calling a subprogram that returns a value, the correct syntax is 'CALL identifier USING ... RETURNING identifier'. The RETURNING clause captures the function's return value. Options B, C, and D use incorrect keywords (RECURRING, RECURSIVE, REFERRING) that are not valid in this context.

Multiple choice technology programming languages
  1. True

  2. False

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

To solve this question, the user needs to understand what the LANGUAGE compiler option and the NATLANG runtime option do.

The LANGUAGE compiler option specifies the programming language used in the code, while the NATLANG runtime option specifies the natural language used in the input and output of the program.

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

A. True: This option is correct. The LANGUAGE compiler option and the NATLANG runtime option are independent of each other. The compiler only needs to know the language being used to compile the code, while the NATLANG runtime option is used to determine the natural language used in input and output. These two options do not interact with each other and can be used independently.

B. False: This option is incorrect. The LANGUAGE compiler option and the NATLANG runtime option can be used independently of each other. They serve different purposes and do not depend on each other.

The Answer is: A

Multiple choice technology programming languages
  1. True

  2. False

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

In COBOL, record areas defined in the FILE SECTION of the DATA DIVISION are accessible to the main program regardless of whether it contains explicit I/O statements. These record areas are part of the program's data storage and can be manipulated like any other data area. The statement is true - I/O statements are for accessing external files, not for accessing internal record areas.

Multiple choice technology programming languages
  1. (1) USING PICTURE Clause

  2. (2) The USAGE IS FUNCTION-POINTER clause

  3. (3) The USAGE IS PROCEDURE-POINTER clause

  4. (4) The USAGE IS FUNCTION-ADDRESS clause

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

To answer this question, the user needs to have knowledge about procedure pointers in COBOL.

Option A is incorrect because the USING PICTURE clause is used to define the picture of data items.

Option B is incorrect because the USAGE IS FUNCTION-POINTER clause is used to define function pointers, not procedure pointers.

Option C is the correct answer. The USAGE IS PROCEDURE-POINTER clause is used to define procedure pointers in COBOL. Procedure pointers are data items that store the addresses of procedures.

Option D is incorrect because the USAGE IS FUNCTION-ADDRESS clause is used to define a data item that stores the address of a function, not a procedure.

Therefore, the answer is:

The Answer is: C. (3) The USAGE IS PROCEDURE-POINTER clause.