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
-
A group of code lines that performs a specific task
-
A group of code lines that performs a whole program
-
Something that contains an ‘init’
-
The purpose of Java
A
Correct answer
Explanation
A function is a modular, reusable block of code that performs a specific task. Option A correctly captures this definition. Option B is incorrect because a function typically performs a sub-task, not an entire program. Option C is too specific (not all functions have 'init'), and Option D is wrong because functions exist in all programming languages, not just Java.
A
Correct answer
Explanation
The finally block always executes when an exception is thrown, regardless of whether a catch block handles it. This is guaranteed behavior except in extreme cases like System.exit() or JVM crash. It ensures cleanup code runs.
-
All Blank values
-
Zeroes to INT and spaces to ALPHA
-
Spaces to INT and Zeroes to ALPHA
-
Zeroes to INT and BLANK to ALPHA
B
Correct answer
Explanation
The INITIALIZE action in Master Craft sets default values for component properties. The default behavior assigns zeroes to integer (INT) type fields and spaces to alphanumeric (ALPHA) type fields, providing clean initial values that can be overwritten during component execution.
B
Correct answer
Explanation
The REPLACE keyword in a COPY statement allows you to substitute specific words or literals, overriding default values supplied by the copied program‑unit. INIT, ASSIGN, and SET do not provide this overriding capability, making REPLACE the correct answer.
-
CONTINUE statement gives control to the verb following the next period.
-
NEXT SENTENCE gives control to the verb after the explicit scope terminator.
-
CONTINUE gives control to the verb after the explicit scope terminator.
-
None of the above
C
Correct answer
Explanation
In COBOL the CONTINUE verb is a no‑operation that passes control to the next executable statement after the current scope terminator, such as the end of a paragraph or section. Therefore the statement that describes CONTINUE giving control after the explicit scope terminator is true.
-
EXAMINE
-
IF THEN ELSE
-
EXHIBIT
-
None of the above
B
Correct answer
Explanation
The COBOL II EVALUATE construct was introduced to replace nested IF‑THEN‑ELSE logic, providing a clearer, multi‑way selection mechanism. It does not relate to EXAMINE or EXHIBIT statements, so the correct choice is IF THEN ELSE. It simplifies complex condition handling by allowing multiple WHEN clauses, thereby serving the same purpose as the traditional IF‑THEN‑ELSE chain.
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.
A
Correct answer
Explanation
JSP allows embedding Java code directly within HTML pages using special tags. While you can technically rename an HTML file to .jsp, the statement describes the basic concept that JSP combines Java logic with HTML presentation. However, the file would need actual Java code in JSP tags to be meaningful.
-
Yes, but the only tags available relate to database access.
-
No. To iterate over a collection of values, one must use scriptlet code.
-
No, but there is a standard <iterate> tag that may be used.
-
Yes, but custom tags will not help developers create tags for use in iterating over a collection.
B
Correct answer
Explanation
Custom tags were introduced in JSP 1.1, not JSP 1.0. To iterate over collections in JSP 1.0, developers had to write scriptlet code (<% %> loops) directly in the JSP page. There was no standard tag in JSP 1.0, and custom tags did not exist at all in that version.
A
Correct answer
Explanation
A JSP tag library is exactly that - a collection of custom tags encapsulating reusable functionality. Tag libraries allow developers to define custom actions that can be used in JSP pages, promoting code reuse and separating presentation from business logic. This is a fundamental concept in JSP tag extension mechanisms.
-
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.
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.