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
B
Correct answer
Explanation
In C++, name lookup is sequential. At the point of x++ in bar(), x has not yet been declared in the namespace. Thus, name lookup fails, and bar() cannot access x without a forward declaration or declaring x first.
A
Correct answer
Explanation
Functions can have OUT parameters in many programming languages and database systems. In Oracle PL/SQL, functions explicitly support OUT parameters. However, this is context-dependent - SQL Server functions do not allow OUT parameters. The question assumes a context where this is valid.
-
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
-
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.
-
TIME=(1,0)
-
ABEND(1,0)
-
TIME=60
-
TIME=1
A
Correct answer
Explanation
The TIME parameter in a JCL job card specifies the maximum CPU time allowed for the job. The format TIME=(minutes, seconds) is used. TIME=(1,0) means the job will abend if it exceeds 1 minute of CPU time. This is the correct syntax for time-based job termination.
-
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.