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

Multiple choice technology programming languages
  1. res is null

  2. res is not null

  3. Run time error

  4. None of the above

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology programming languages
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology mainframe
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology programming languages
  1. Program C compilation and linkedit is enough

  2. Program A ,Program B and Program C should be compiled

  3. Program A and Program C should be compiled

  4. Program B will have to be relinked with Program C

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology programming languages
  1. The instance gets garbage collected.

  2. The code on line 33 throws an exception.

  3. The code on line 35 throws an exception.

  4. The code on line 31 throws an exception.

  5. The code on line 33 executes successfully.

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology mainframe
  1. it should be defined as GLOBAL

  2. should be included in the linkage section

  3. Both a and b

  4. Cannot be used

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology mainframe
  1. it should be defined as GLOBAL

  2. should be included in the linkage section

  3. Both a and b

  4. Cannot be used

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology mainframe
  1. it should be defined as GLOBAL

  2. should be defined in the linkage section

  3. Should be defined with the same name in both programs

  4. Cannot be used

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology mainframe
  1. using the RETURN-CODE variable in program

  2. passing as an ouput from program

  3. cannot set the return code

  4. Using the SET-CODE statement in program

Reveal answer Fill a bubble to check yourself
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.