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
-
It's the same as a constant
-
It's value can be assigned only once
-
You can never assign a value to it
-
You can assign value multiple times
B
Correct answer
Explanation
A readonly field in C# can only be assigned a value during its declaration or within the class's constructor. Once the constructor finishes, its value becomes immutable. This differs from constants, which must be known at compile-time, and regular variables, which can be reassigned multiple times.
-
DLLImport
-
UsingDLL
-
DLLCall
-
CallDLL
A
Correct answer
Explanation
DllImport is the attribute used in C# to call methods from unmanaged code, including COM objects and native DLLs. The syntax is [DllImport("dllname.dll")] for external method declarations. The other options (UsingDLL, DLLCall, CallDLL) are not valid C# keywords or attributes.
-
delegate {TheMethod( int Z) }
-
delegate void TheMethod(int Z) ;
-
delegate: TheMethod (int Z)
-
delegate: {TheMethod (int Z)}
B
Correct answer
Explanation
The correct delegate declaration syntax in C# is 'delegate returnType MethodName(parameters)'. Option B shows this correctly: 'delegate void TheMethod(int Z)'. The other options use incorrect syntax with braces, colons, or missing return types.
-
char * (f* (*) ))
-
char * ( f) (()());
-
(char) (f) (());
-
(char) (*f) ()();
B
Correct answer
Explanation
This declares a function pointer 'f' that returns a char pointer and takes one argument - a pointer to a function taking no arguments and returning nothing. The syntax is 'char (*f)(void ()(void))' or equivalent with spacing. Option B's parenthetical structure, despite spacing oddities, best represents this complex declaration.
D
Correct answer
Explanation
In REXX, the LEAVE statement causes immediate exit from the current DO-END loop and execution continues with the statement following END. The EXIT statement would terminate the entire program, not just the loop. FINISH is not a REXX keyword.
-
The above exec will prompt the user for a code until the user enters the code ‘BYE’
-
The above exec will prompt the user for a code until the user enters the code ‘EXIT’.
-
Gives Error while Executing
-
The above exec will prompt the user for a code until the user enters the code ‘END’.
A
Correct answer
Explanation
The REXX script uses a Do forever loop to repeatedly prompt the user and read input using Pull code. The Pull instruction converts input to uppercase. If the input matches 'BYE', the Leave statement terminates the loop, and the program exits. Other options specify incorrect termination conditions.
-
Type N
-
Type C
-
Type F
-
Type P
C
Correct answer
Explanation
In SAP ABAP, the PARAMETERS statement can only use data types N (numeric text), C (character), and P (packed decimal). Type F (floating-point) is not allowed for PARAMETERS because it can cause precision issues and is not suitable for user input parameters. Floating-point types are better suited for internal calculations.
-
deletes buffer in the stack
-
deletes buffer and all elements of stack
-
deletes elements of stack
-
All the above
B
Correct answer
Explanation
In SAP, the DROPBUF 0 command deletes the buffer and ALL elements of the stack. The argument '0' specifies deleting all buffers and stack contents. Option A is incomplete (only buffer), Option C is incomplete (only stack elements), so Option B correctly describes the complete action.
A
Correct answer
Explanation
The COBOL PERFORM statement, especially when used with the UNTIL phrase, functions as a conditional loop. This is equivalent to DO WHILE or while loops in Java or C++. IF is a conditional branch, METHOD is a function definition, and FOR is a different loop structure.
-
Used to initialize some value to a variable
-
Numeric values are set to zero, alphabetic and alphanumberic variables are set to spaces.
-
All variables are set to spaces.
-
None of the above
B
Correct answer
Explanation
The INITIALIZE verb sets numeric data to zeros and alphanumeric/alphabetic data to spaces. It's a convenient way to reset data items to their default empty values without setting each one individually.
-
Will contain zeroes if numeric and spaces if alphabetic or alphanumeric
-
Will contain spaces for all variables
-
Will contain an undefined value
-
None of the above
C
Correct answer
Explanation
In COBOL, uninitialized variables contain whatever garbage data happens to be in their allocated memory location, making their initial value undefined. They do not automatically default to spaces or zeroes unless explicitly initialized using the VALUE clause or the INITIALIZE statement.
-
Function Module
-
Subroutinue
-
Macro
-
Event
A
Correct answer
Explanation
The interface between an application program and a Smart Form is a Function Module. When a Smart Form is activated, the system automatically generates a function module that serves as the interface, allowing the application program to call and execute the form.
-
Buffers are always used
-
Choice of buffer can be made to use
-
Buffers are always bypassed
-
None of above
C
Correct answer
Explanation
In inner and outer joins, buffers are always bypassed because the database must access the actual table data to perform the join operation correctly across tables. Using buffered data could produce inconsistent results since buffers only contain individual table data.
-
Load & PreLoad
-
Preload & PostStore
-
Load & Store
-
Store & PreStore
C
Correct answer
Explanation
In business workflow implementation, Load and Store subroutines are used to handle business tasks. Load fetches data at the start, and Store saves results after processing. The other combinations are not standard subroutine pairs in this context.