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 mainframe
  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

In COBOL, a PERFORM … UNTIL loop executes its body first and then checks the termination condition, matching the semantics of a do‑while loop in languages like Java or C++. A traditional for loop evaluates the condition before the first iteration, so the correct correspondence is a do‑while construct.

Multiple choice technology mainframe
  1. There is no limit

  2. 1

  3. 2

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

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

In COBOL, a single IF statement can make exactly one comparison. The structure is IF condition THEN statement-1 ELSE statement-2, where the condition is a single relational test. Multiple comparisons require nested IF statements or combined conditions with AND/OR, but each IF statement itself evaluates one condition.

Multiple choice technology mainframe
  1. Infinite loop

  2. Logical Error

  3. All of the above

  4. None of the abov

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

A COBOL IF statement itself cannot cause infinite loops (that requires PERFORM/GO TO), and syntax errors would be caught at compile time, not runtime logical errors. The statement asks which errors are possible 'within a COBOL if statement' - meaning inherent to the IF construct itself, not in the statements it executes. The answer is that none of these error types are inherent to IF.

Multiple choice technology mainframe
  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

COBOL's PERFORM ... UNTIL structure executes at least once before checking the condition, which is the defining behavior of a post-test loop like do-while in Java/C++. While PERFORM ... VARYING resembles a for loop, the generic 'perform loop' term typically refers to the UNTIL variant, making do-while the best match.

Multiple choice technology programming languages
  1. True

  2. False

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

In component-based design, components encapsulate their internal implementation details. A dependent component A can only access operations that component B explicitly exposes through its public interfaces, rather than all internal operations defined within B. This encapsulation ensures loose coupling.

Multiple choice technology programming languages
  1. Header

  2. Declarative

  3. Executable

  4. Exception

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

To solve this question, the user needs to understand the structure of a PL/SQL block and the purpose of each section.

The PL/SQL block is divided into the following sections:

  1. Header: This section is optional and contains comments and declarations of global variables and cursors.

  2. Declarative: This section is optional and contains declarations of local variables, cursors, types, and subprograms.

  3. Executable: This section is mandatory and contains the code that performs the desired operations.

  4. Exception: This section is optional and contains handlers for exceptions that may be raised during the execution of the executable section.

The correct answer is:

D. Exception

Functions for error trapping are contained in the exception section of a PL/SQL block. This section contains handlers for exceptions that may occur during the execution of the executable section. These handlers allow the program to gracefully handle errors and continue executing, rather than crashing or terminating unexpectedly.

Multiple choice technology web technology
  1. function myFunction()

  2. function=myFunction()

  3. function:myFunction()

  4. function myFunction

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

Functions in JavaScript are created using the 'function' keyword followed by the function name and parentheses: function myFunction(). The equals sign or colon are not part of function declaration syntax.

Multiple choice technology web technology
  1. call myFunction()

  2. call function myFunction

  3. myFunction()

  4. call function myFunction()

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

To call a function in JavaScript, simply write the function name followed by parentheses: myFunction(). The 'call' keyword is not used in JavaScript - that's a different language. Functions are invoked by using their name directly.

Multiple choice technology web technology
  1. while (i<=10)

  2. while (i<=10;i++)

  3. while i=1 to 10

  4. while (i=0;i<=10;i++)

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

A while loop in C-style syntax requires a condition in parentheses: while (condition). Option B incorrectly adds i++ which is for-loop syntax, and options C and D use Pascal/BASIC style (for i=1 to 10) or full for-loop syntax respectively.