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
-
Link option is AMODE=24 and RMODE=ANY. Compile option should have SIZE(MAX).
-
Link option is AMODE=31 and RMODE=31. Compile option should not have SIZE(MAX).
-
Link option is AMODE=24 and RMODE=24. Compile option should not have SIZE(MAX).
-
Link option is AMODE=31 and RMODE=ANY. Compile option should not have SIZE(MAX).
D
Correct answer
Explanation
To execute programs above the 16 MB line in mainframe systems, you need AMODE=31 (31-bit addressing mode) with RMODE=ANY (allow any residency mode), and avoid SIZE(MAX) compile option. Option A is wrong because AMODE=24 limits to below the line. Option B incorrectly specifies RMODE=31 instead of ANY. Option C is wrong because AMODE=24 is for below-line programs.
D
Correct answer
Explanation
The variable ws-var is defined as PIC 9(1), which can only hold single-digit values (0-9). The PERFORM increments ws-var from 1 by 1 until ws-var > 10. When ws-var goes from 9 to 10, the PIC 9(1) truncates 10 to 0, then continues cycling 0-1-2-...-9-0 forever, never reaching >10. This creates an infinite loop.
B
Correct answer
Explanation
A mapset can contain multiple maps, not just one. A single mapset is a collection of one or more maps that are logically grouped together and loaded together into CICS. This allows related screens to be organized and maintained as a unit.
B
Correct answer
Explanation
COBOL COPY statements are expanded during the PRECOMPILE stage, not the pre-compile stage. The precompiler processes COPY statements by inserting the copied text into the source program before the actual compilation begins. This is a critical distinction in the COBOL/DB2 compilation process.
-
Entry will enter the main program and execute it.
-
Specifies the program entry.
-
It establishes an alternate entry point into a COBOL called subprogram.
-
ENTRY is not a COBOL keyword
C
Correct answer
Explanation
The ENTRY statement in COBOL is used to establish an alternate entry point in a called subprogram, allowing execution to begin at a place other than the start of the Procedure Division.
-
Invalid Syntax
-
Specifies the end of a called program and returns control to the calling program.
-
Specifies the end of a called program.
-
Specifies the end of a calling program.
B
Correct answer
Explanation
The EXIT PROGRAM statement in COBOL specifies the logical end of a called subprogram and returns control back to the calling program.
-
Loop the program
-
What is RECURSIVE?
-
Recursively reenters
-
Recursively reenters only for CICS program
C
Correct answer
Explanation
The RECURSIVE clause in the PROGRAM-ID paragraph specifies that the COBOL program can be recursively reentered while an active call to it is still in progress, allowing recursive execution.
-
It marks the end of certain Procedure Division statements.
-
It marks the end of certain looping condition statements.
-
It marks the end of program.
-
There is nothing like EXPLICIT SCOPE TERMINATOR in COBOL
A
Correct answer
Explanation
Explicit scope terminators in COBOL (like END-IF, END-PERFORM) mark the end of specific Procedure Division statements. They provide clear boundaries for conditional and looping constructs, improving code readability and preventing ambiguity in nested structures.
-
x as integer and y as integer.
-
x as variant and y as integer.
-
x as integer and y as variant.
-
x as double and y as integer.
B
Correct answer
Explanation
In Visual Basic, the statement 'Dim x, y as integer' declares x as a Variant (default type) and y as Integer. The 'As Integer' type declaration only applies to the variable immediately preceding it (y), not to x. This is a common VB quirk in multiple variable declarations.
A
Correct answer
Explanation
The Timer control in Visual Basic 6.0 has exactly one primary event: the Timer event, which fires repeatedly at the interval specified by the Interval property. This single event makes the Timer control useful for creating time-based operations without multiple event handlers.
-
Syntax Errors
-
System Errors
-
Runtime Errors
-
Logic Errors
A,C,D
Correct answer
Explanation
Visual Basic has three main error categories: Syntax Errors (caught during compilation when code structure is invalid), Runtime Errors (occur during program execution like division by zero), and Logic Errors (program runs but produces incorrect results due to flawed logic). 'System Errors' is not a standard VB error classification.
A
Correct answer
Explanation
Java APIs are pre-compiled code libraries that provide ready-to-use functionality. These packages (like java.lang, java.util, java.io) contain compiled classes and methods that developers can import and use without rewriting common functionality. This is fundamental to Java's 'batteries included' approach.
-
Inside TRY Inside FINALLY
-
Inside TRY
-
Inside TRY Inside CATCH Inside FINALLY
-
None of the above
B
Correct answer
Explanation
Option B Float.isNan(x) is the correct approach for checking NaN. Option A x == Float.NaN is always false because NaN is not equal to anything including itself (IEEE 754 rule). Option C depends on MyObject's equals implementation - most objects won't handle NaN comparison correctly. B is the only valid answer.
-
Wait
-
Exist
-
Both A & B
-
None
C
Correct answer
Explanation
Both Wait and Exist statements can instruct QTP to wait for an object. The Wait statement pauses execution for a specified time, while Exist checks if an object exists and can be used in a loop to wait for the object to appear. Both achieve the goal of waiting until an object exists.