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 programming languages
  1. 1

  2. 2

  3. There is no limit

  4. COBOL if statements are not used to compare variable values

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

A single COBOL IF statement can make only 1 comparison. The IF statement in COBOL evaluates a single condition at a time, though multiple comparisons can be combined using logical operators like AND or OR in nested IF statements or EVALUATE statements. However, a basic IF statement structure (IF condition THEN statement-1 ELSE statement-2) contains exactly one condition check. This design reflects COBOL's emphasis on simple, readable conditional logic.

Multiple choice technology programming languages
  1. Infinite loop

  2. Logical Error

  3. Runtime error

  4. All of the above

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

All three types of errors can occur within a COBOL IF statement. An infinite loop can result if the IF condition never becomes false and controls a loop structure. A logical error occurs when the condition is incorrectly specified, causing the program to take the wrong branch. A runtime error can happen if the IF statement involves invalid data operations like division by zero or invalid type comparisons. The IF statement's logic must be carefully designed to avoid all these error types.

Multiple choice technology programming languages
  1. For loop

  2. Do-While loop

  3. Method

  4. None of the above

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

The COBOL PERFORM loop is equivalent to a Do-While loop found in other procedural languages. Like a Do-While loop, the PERFORM...UNTIL structure executes the loop body at least once before checking the termination condition. The 'UNTIL' clause specifies the condition that, when true, causes the loop to exit. This behavior differs from a While loop (which checks the condition before execution) but matches the Do-While pattern of execute-then-check.

Multiple choice technology programming languages
  1. Use a standard perform statement

  2. Use an in line perform

  3. Skillful use of the COBOL reserved word "AFTER"

  4. This is not possible in COBOL

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

In COBOL, to execute a PERFORM loop once before the condition is checked, you would use a PERFORM...WITH TEST AFTER clause or construct the loop with the condition checked at the end. However, the question references 'skillful use of the AFTER' clause, which in COBOL's PERFORM VARYING syntax allows you to specify when the condition is evaluated. By placing the condition check appropriately in a PERFORM...UNTIL or PERFORM...VARYING structure, you can ensure the loop body executes at least once before termination conditions are evaluated.

Multiple choice technology programming languages
  1. Exits the statement

  2. Executes the function

  3. Exits the Program

  4. Executes the If statement again

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

When an IF condition evaluates to true, the program immediately branch-executes the block of statements nested under the IF statement. Exiting the statement or program are incorrect because they bypass or terminate normal execution.

Multiple choice technology programming languages
  1. True

  2. False

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

COBOL is designed to be self-documenting because it uses English-like syntax with verbs and nouns that read like natural language sentences. For example: 'MOVE total TO final-total' clearly describes what the code does without requiring additional comments.

Multiple choice technology databases
  1. variables and constants

  2. cursors

  3. exceptions

  4. All of the above

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

Procedures, functions, and packages in PL/SQL (or similar database languages) include multiple programming constructs: variables and constants for data storage, cursors for querying data row-by-row, and exceptions for error handling. All of these (option D) are valid constructs.

Multiple choice technology testing
  1. I, II, III and IV

  2. I, III and IV

  3. V only

  4. II, III and IV

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

When a human makes a mistake writing code, it's called an ERROR. This error can introduce a FAULT (defect) in the code. When the faulty code executes, it may produce a BUG (unexpected behavior), and if this bug causes the system to deviate from specified requirements, it's a FAILURE. Defect is often used synonymously with fault or bug. So the chain is: human mistake → error → fault/defect in code → bug → failure.

Multiple choice technology databases
  1. True

  2. False

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

Actual parameters are the values or expressions passed in a subprogram call. They are the real data being supplied to the subroutine when it's invoked. This contrasts with formal parameters, which are the variable declarations in the subprogram's specification that define what parameters it accepts.

Multiple choice technology databases
  1. True

  2. False

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

Formal parameters are the variables declared in a subprogram's header or specification. They serve as placeholders for the values that will be passed when the subprogram is called. These are referenced within the subprogram body to work with the data provided through actual parameters.

Multiple choice technology mainframe
  1. Marks the end of a job

  2. Marks the beginning of an instream procedure

  3. Marks the beginning of a job & assigns a name to the job

  4. Assigns an execution priority to a job

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

The JOB statement marks the beginning of a job and assigns a name to it. It's the first statement in any JCL job and provides the job identifier used throughout the execution. Options A and C describe end markers, option D describes PRTY or MSGLEVEL parameters. The JOB statement is fundamental to JCL job structure.

Multiple choice technology mainframe
  1. Call

  2. Perform

  3. Callnat

  4. None of the above

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

CALLNAT is the correct Natural statement for invoking subprograms (also called external subroutines). 'Call' and 'Perform' are not valid Natural statements for this purpose - Natural uses specific keywords like CALLNAT, FETCH, or CALL for different types of module invocations. CALLNAT specifically calls Natural subprograms that are compiled separately from the calling program.

Multiple choice technology mainframe
  1. *TIMD

  2. *TIMY

  3. *TIME-OUT

  4. *TIMN

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

Natural system variables start with an asterisk. Among the choices, *TIMD (time time-of-day), *TIME-OUT (inactive time limit), and *TIMN (time numeric) are valid system variables in Natural. *TIMY is not a valid system variable; *DATY is used for the year or date in other formats.