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
B
Correct answer
Explanation
Option B Float.isNan(x) is the correct approach for checking NaN. Option A x == Float.NaN is always false because NaN is not equal to anything including itself (IEEE 754 rule). Option C depends on MyObject's equals implementation - most objects won't handle NaN comparison correctly. B is the only valid answer.
-
Wait
-
Exist
-
Both A & B
-
None
C
Correct answer
Explanation
Both Wait and Exist statements can instruct QTP to wait for an object. The Wait statement pauses execution for a specified time, while Exist checks if an object exists and can be used in a loop to wait for the object to appear. Both achieve the goal of waiting until an object exists.
-
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.
-
Delimits the PROC control statements
-
Identifies the control card library
-
Marks the beginning of one or more program control statements
-
None of the above
C
Correct answer
Explanation
In JCL (Job Control Language), the //CNTL statement marks the beginning of one or more program control statements that will be passed to the program. It delimits control statements from regular job statements. Options A and B describe different JCL functions.
-
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
-
Delimits the PROC control statements
-
Identifies the control card library
-
Marks the beginning of one or more program control statements
-
None of the above
C
Correct answer
Explanation
In JCL (Job Control Language for IBM mainframes), the //CNTL statement marks the beginning of one or more program control statements that follow. It's used to pass control information to programs like IEBGENER, SORT, or utilities. The CNTL statement delimits where these control statements start and is followed by the actual control cards.
-
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).