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
-
Struct
-
Delegate
-
string
-
Enumeration
C
Correct answer
Explanation
In C#, string is a reference type, not a value type. Value types include structs, enums, and primitive types (int, bool, etc.). Delegates are also reference types. When you assign a string variable, you're copying a reference, not the actual string data.
A
Correct answer
Explanation
Exception handling in languages like C++ incurs a runtime performance penalty due to the machinery required for stack unwinding and maintaining tables for exception safety.
-
string [,,] aMatrix;
-
string [][][] aMatrix;
-
int [][]aInt= new int[3][];
-
None of the above.
C
Correct answer
Explanation
A jagged array in C# is an array-of-arrays where each inner array can have different lengths. The syntax int [][]aInt = new int[3][]; creates a jagged array with 3 rows, where each row can be initialized separately with different lengths. Option A is a 3D rectangular array. Option B is also rectangular. Jagged arrays use [][] syntax.
-
Struct
-
Delegate
-
string
-
Enumeration
A
Correct answer
Explanation
Java APIs are indeed libraries of pre-compiled code that provide reusable functionality for developers.
-
Struct
-
Delegate
-
string
-
Enumeration
-
string [,,] aMatrix;
-
string [][][] aMatrix;
-
int [][]aInt= new int[3][];
-
None of the above.
C
Correct answer
Explanation
A jagged array in C# is an array-of-arrays where each inner array can have different lengths. The syntax uses two sets of brackets: 'int[][]' or 'int[][] = new int[3][]'. Option C shows this correctly. Options A and B are rectangular/multi-dimensional arrays (commas between brackets), not jagged arrays. Jagged arrays are declared and initialized with '[]' syntax, not '[,,]' syntax.
-
Struct
-
Delegate
-
string
-
Enumeration
C
Correct answer
Explanation
In C#, value types are primitive types that store data directly. Struct, Delegate, and Enumeration are all value types. string is a reference type - it's an object that stores a reference to the actual string data on the heap, not the data itself.
A
Correct answer
Explanation
Java APIs consist of pre-compiled classes and interfaces packaged in JAR files that provide reusable functionality. They contain bytecode that the JVM can execute, making them libraries of compiled code.
-
The code on line 31 throws an exception
-
The code on line 33 throws an exception
-
The code on line 35 throws an exception
-
The code on line 33 executes successfully
B,C,D
Correct answer
Explanation
The finally block on line 37 always executes regardless of how the try-catch block exits. This includes successful execution of the try block (line 33), or when an exception is thrown in the try block (line 33) or catch block (line 35).
-
Always returns a value.
-
Never returns a value.
-
Returns when RC is coded
-
I am skipping this!!
C
Correct answer
Explanation
In REXX, the EXIT instruction terminates the program immediately. It can optionally return a value to the caller (such as the operating system or another script) if an expression or a Return Code (RC) variable is provided. Without an expression, it returns no value. The other options are incorrect because returning a value is optional, not mandatory or impossible.
-
TIME()
-
TIME(E)
-
TIME(L)
-
TIME(M)
B
Correct answer
Explanation
TIME(E) in REXX returns elapsed time in the format sssssssss.mmmmmm (seconds.microseconds). TIME() defaults to civil time, TIME(L) gives long local time, and TIME(M) returns minutes.
-
DROP
-
DELSTACK
-
DELETE
-
Cant delete a stack
B
Correct answer
Explanation
DELSTACK is the REXX command to delete/remove a stack. DROP is for variables, DELETE isn't used for stacks, and stacks can be deleted.
-
serialization
-
garbage collection
-
assemblies
-
overriding
B
Correct answer
Explanation
Garbage collection is the automatic memory management technique in .NET framework that automatically reclaims memory occupied by objects that are no longer in use. Serialization is about object persistence, assemblies are deployment units, and overriding is a polymorphism concept - none relate to memory management.