Computer Knowledge

Programming Fundamentals

2,381 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 programming languages
  1. INTOEMPTY

  2. OBJECTS

  3. Only b

  4. Both a and b

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

To solve this question, the user needs to have knowledge of the IMPORT command in SQL.

The correct answer is:

D. Both a and b

Explanation:

The IMPORT command is used to import data from an external file into a SQL database. The IMPORT command has several parameters, one of which is the "PARAMETERS" parameter. The "PARAMETERS" parameter has several subcommands, including "INTOEMPTY" and "OBJECTS".

  • The "INTOEMPTY" subcommand is used to import data into an empty table.
  • The "OBJECTS" subcommand is used to import data into an existing table.

Therefore, option D is correct because both subcommands "INTOEMPTY" and "OBJECTS" are subcommands of the IMPORT parameter.

Multiple choice technology databases
  1. It produces the output Procedure B calling C

  2. It produces the output Procedure C calling B

  3. It produces a compilation error because procedure C requires a forward declaration

  4. It produces a compilation error because procedure B requires a forward declaration.

  5. It produces a compilation error because identified g_value is not declared in procedure A

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

The package has a circular reference problem: procedure C calls procedure B, but procedure C appears before procedure B in the package body. Without a forward declaration, procedure C cannot find procedure B when compiling, resulting in an error. Option C correctly identifies this forward declaration issue for procedure C. Option D is incorrect because procedure B does NOT need a forward declaration - it appears later in the code and is visible to C. Options A and B are incorrect because the code cannot produce any output - it fails to compile.

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) 20

  2. (b) 29

  3. (c) 28

  4. (d) 18

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

In IBM COBOL with ARITH(COMPAT) compiler option, the FACTORIAL function accepts integer arguments from 0 to 28 maximum. This is due to the storage size limitations for the result - values beyond 28! exceed standard numeric representation capacity.

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