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. Virtual functions

  2. Inline functions

  3. Static functions

  4. Friend functions

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Inline functions are expanded at compile time - the compiler replaces the function call with the actual function code, eliminating the overhead of function call mechanism. Virtual functions use dynamic binding, static functions have class scope, and friend functions are non-member functions with special access rights.

Multiple choice technology programming languages
  1. Void

  2. Int

  3. Bool

  4. none of the above

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In C++, if no return type is specified for a function, the default return type is 'int'. This is a legacy feature from C. However, it's considered poor practice - always explicitly specify the return type. The 'void' return type means the function returns nothing, while 'bool' is for boolean return values.

Multiple choice technology programming languages
  1. Reference types are stored on stack and value types are stored on heap area.

  2. Boxing allows you to convert value types to reference types.

  3. For boxing, during runtime it creates a temporary reference type box for the object on the heap

  4. Unboxing allows you to convert reference type to value type

Reveal answer Fill a bubble to check yourself
B,C,D Correct answer
Explanation

In C#, boxing converts value types to reference types, and unboxing reverses this. During boxing, the runtime creates a temporary reference type object on the heap to hold the value type. Reference types are stored on the heap, not the stack (option A is wrong), and identifiers can contain numeric characters (option D is wrong).

Multiple choice technology programming languages
  1. In C#, we can define one and only one main( ) method .

  2. If there is more than one main( ) method defined in your programme ,the compiler will return compile time error.

  3. If there is more than one main( ) method defined you can explicitely tell the compiler which main( ) method is to be used as the entry point.

  4. All the statements are wrong

Reveal answer Fill a bubble to check yourself
B,C Correct answer
Explanation

C# allows multiple Main() methods in different classes, but you must specify which one is the entry point using compiler options. The compiler returns an error if multiple Main() methods exist without an explicit entry point specification. Option A is wrong because you CAN define multiple Main() methods.

Multiple choice technology programming languages
  1. These are the names that one user gives to variables such as the user defined types(eg;classes and structs)

  2. These are not case sensitive.

  3. Their names must begin with a letter or with a underscore .

  4. They must not contain any numeric characters

Reveal answer Fill a bubble to check yourself
A,C Correct answer
Explanation

C# identifiers are names for variables, classes, structs, etc. They must begin with a letter or underscore, are case-sensitive (option B is wrong), and can contain numeric characters after the first character (option D is wrong).

Multiple choice technology mainframe
  1. For loop

  2. Do-while loop

  3. method

  4. None of the above

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

COBOL's PERFORM...UNTIL executes the loop body first, then checks the condition - similar to do-while in Java/C++ (condition checked at bottom, guaranteed at least one iteration). PERFORM...VARYING is more like a for loop.

Multiple choice technology mainframe
  1. Use a standard perform statement

  2. Use an in line perform

  3. Skillful use of the COBOL reserved word "AFTER"

  4. This is not possible in COBOL

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The PERFORM statement with the AFTER clause in COBOL creates a loop that executes the body first, then checks the condition for subsequent iterations. This is equivalent to a do-while loop in other languages.

Multiple choice technology mainframe
  1. Bad coding. The loop will not be executed.

  2. 5 times.

  3. 10 times.

  4. 15 times.

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

WS-N starts at 0, gets set to 5, then PERFORM B-PARA WS-N TIMES executes B-PARA exactly 5 times. The fact that B-PARA changes WS-N to 10 doesn't affect the loop count - PERFORM TIMES evaluates the count once at the start.

Multiple choice technology mainframe
  1. Link option is AMODE=24 and RMODE=ANY. Compile option should have SIZE(MAX).

  2. Link option is AMODE=31 and RMODE=31. Compile option should not have SIZE(MAX).

  3. Link option is AMODE=24 and RMODE=24. Compile option should not have SIZE(MAX).

  4. Link option is AMODE=31 and RMODE=ANY. Compile option should not have SIZE(MAX).

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

Multiple choice technology mainframe
  1. COND codes

  2. IF statement

  3. both

  4. Non of These

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

In JCL, conditional processing can be achieved through COND parameters on job steps (which execute/conditionally skip steps based on return codes) or IF/THEN/ELSE/ENDIF statements that provide logical control flow within the job. Both mechanisms allow skipping steps based on specified conditions.

Multiple choice technology mainframe
  1. 10

  2. 11

  3. 9

  4. infinite Loop

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