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
-
res is null
-
res is not null
-
Run time error
-
None of the above
B
Correct answer
Explanation
The Where() method returns an IEnumerable sequence, never null. Even when no elements match the predicate (n==D), it returns an empty enumerable, not null. The condition res==null is always false for LINQ query results, so res is not null prints. This is a common misconception about empty sequences.
B
Correct answer
Explanation
Although anonymous types are heavily used in LINQ queries to project query results, they are technically a feature of the C# and VB.NET compilers rather than the LINQ framework itself. Thus, the statement is technically false, as the language supports anonymous types independently of LINQ.
A
Correct answer
Explanation
Programs called from JCL can set return codes which become the JCL step completion code (condition code). In COBOL, this is done with RETURN-CODE special register. In other languages, exit codes serve the same purpose. The JCL can then test these codes with COND parameters.
-
Data Exception Error
-
ABCDE ABCDE
-
ABCDE bbbbb
-
Compilation error
-
Program C compilation and linkedit is enough
-
Program A ,Program B and Program C should be compiled
-
Program A and Program C should be compiled
-
Program B will have to be relinked with Program C
D
Correct answer
Explanation
When B is statically linked to C, C's code is embedded in B at link time. If C changes, B must be recompiled and relinked to incorporate the new version. A doesn't need recompilation because it links dynamically to B - it will use the updated B at runtime. Only B needs relinking.
-
The instance gets garbage collected.
-
The code on line 33 throws an exception.
-
The code on line 35 throws an exception.
-
The code on line 31 throws an exception.
-
The code on line 33 executes successfully.
B,C,E
Correct answer
Explanation
The finally block on line 37 always executes unless the JVM exits. It runs if the try block succeeds, if an exception is thrown in the try block (caught or uncaught), or if an exception is thrown in the catch block.
-
it should be defined as GLOBAL
-
should be included in the linkage section
-
Both a and b
-
Cannot be used
C
Correct answer
Explanation
In COBOL, to use a variable from a main program in a subprogram, it must be defined as GLOBAL in the main program to make it accessible across programs. Additionally, it should be included in the linkage section of the subprogram to establish the communication between programs. Both requirements are necessary for proper data sharing.
-
cannot set the return code
-
using the RETURN-CODE variable in program
-
passing as an ouput from program
-
Using the SET-CODE statement in program
-
it should be defined as GLOBAL
-
should be included in the linkage section
-
Both a and b
-
Cannot be used
C
Correct answer
Explanation
In COBOL and similar mainframe languages, sharing variables between main and sub programs typically involves both: (1) defining variables appropriately (sometimes as GLOBAL or external), and (2) including them in the LINKAGE SECTION for parameter passing. The exact mechanism depends on the language and call method.
-
it should be defined as GLOBAL
-
should be defined in the linkage section
-
Should be defined with the same name in both programs
-
Cannot be used
A,B
Correct answer
Explanation
Similar to 150625, this asks about sharing variables between main and sub programs. In mainframe contexts like COBOL, variables are typically defined as GLOBAL/external AND included in the LINKAGE SECTION for proper parameter passing between programs.
-
using the RETURN-CODE variable in program
-
passing as an ouput from program
-
cannot set the return code
-
Using the SET-CODE statement in program
-
using the RETURN-CODE variable in program
-
passing as an ouput from program
-
cannot set the return code
-
Using the SET-CODE statement in program
A
Correct answer
Explanation
In COBOL, REXX, and other mainframe languages, you CAN set the JCL return code. The RETURN-CODE special register (in COBOL) or equivalent mechanisms allow programs to control the completion code passed back to JCL. This is fundamental for job flow control.
C
Correct answer
Explanation
The @_ array stores all parameters passed to a Perl subroutine. Each element can be accessed as $[0], $[1], etc. The other options are different special variables: $# is the last index of an array, $@ is the error message from eval, and @ alone is not a valid special variable.
D
Correct answer
Explanation
The redo statement restarts the current loop iteration without re-evaluating the loop condition. Unlike next (which skips to next iteration) or last (which exits the loop), redo repeats the same iteration from the beginning. 'repeat' and 'recall' are not Perl loop control keywords.