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
-
Virtual functions
-
Inline functions
-
Static functions
-
Friend functions
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.
C
Correct answer
Explanation
A Null pointer is a pointer of any data type that does not point to any valid memory location and generally holds a value of zero. Vptr is a virtual table pointer, Void represents a pointer to an unspecified data type, and Zero is not a standard pointer type.
-
Void
-
Int
-
Bool
-
none of the above
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.
-
Reference types are stored on stack and value types are stored on heap area.
-
Boxing allows you to convert value types to reference types.
-
For boxing, during runtime it creates a temporary reference type box for the object on the heap
-
Unboxing allows you to convert reference type to value type
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).
-
In C#, we can define one and only one main( ) method .
-
If there is more than one main( ) method defined in your programme ,the compiler will return compile time error.
-
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.
-
All the statements are wrong
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.
-
These are the names that one user gives to variables such as the user defined types(eg;classes and structs)
-
These are not case sensitive.
-
Their names must begin with a letter or with a underscore .
-
They must not contain any numeric characters
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).
-
Infinite loop
-
Logical Error
-
Runtime Error
-
All of the above
-
For loop
-
Do-while loop
-
method
-
None of the above
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.
-
Use a standard perform statement
-
Use an in line perform
-
Skillful use of the COBOL reserved word "AFTER"
-
This is not possible in COBOL
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.
-
Exits the statement
-
Executes the function
-
Exits the Program
-
Executes the If statement again
B
Correct answer
Explanation
When an IF condition evaluates to true, the statements within the THEN branch (the code block associated with the true condition) are executed as part of normal program flow.
-
Bad coding. The loop will not be executed.
-
5 times.
-
10 times.
-
15 times.
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.
-
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.
-
COND codes
-
IF statement
-
both
-
Non of These
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.
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.
A
Correct answer
Explanation
REFERBACK allows execution of programs from any library by maintaining a reference to the original program location, enabling flexible program execution in mainframe environments. This mechanism provides access to programs across different libraries.