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
B
Correct answer
Explanation
The EVALUATE statement evaluates all WHEN clauses independently, similar to a case statement, so the order does not affect which clause matches. Therefore the statement about order being significant is false, making the ‘False’ option the correct answer.
-
For loop
-
Do-While loop
-
Method
-
None of the Above
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.
-
There is no limit
-
1
-
2
-
COBOL if statements are not used to compare variable values
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.
-
Infinite loop
-
Logical Error
-
All of the above
-
None of the abov
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.
-
For loop
-
Do-While loop
-
Method
-
None of the Above
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.
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.
A
Correct answer
Explanation
ALTER SEQUENCE modifies future sequence numbers only. Numbers already allocated to the session cache (typically 20) are not affected. Changes impact the next sequence value generated, not values already used or cached.
-
Header
-
Declarative
-
Executable
-
Exception
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:
Header: This section is optional and contains comments and declarations of global variables and cursors.
Declarative: This section is optional and contains declarations of local variables, cursors, types, and subprograms.
Executable: This section is mandatory and contains the code that performs the desired operations.
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.
-
NULL
-
0
-
Results in a compilation error
-
An exception will be raised
-
Header
-
Declarative
-
Executable
-
Exception
-
function myFunction()
-
function=myFunction()
-
function:myFunction()
-
function myFunction
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.
-
call myFunction()
-
call function myFunction
-
myFunction()
-
call function myFunction()
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.
-
while (i<=10)
-
while (i<=10;i++)
-
while i=1 to 10
-
while (i=0;i<=10;i++)
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.
A
Correct answer
Explanation
A for‑each loop iterates over each element of a collection, repeating the enclosed task for every object. This description is accurate, making the True answer correct.