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. A

  2. B

  3. Both

  4. None of these

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

Multiple choice technology testing
  1. Wait

  2. Exist

  3. Both A & B

  4. None

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

Multiple choice technology programming languages
  1. Struct

  2. Delegate

  3. string

  4. Enumeration

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

Multiple choice technology mainframe
  1. Delimits the PROC control statements

  2. Identifies the control card library

  3. Marks the beginning of one or more program control statements

  4. None of the above

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

Multiple choice technology programming languages
  1. string [,,] aMatrix;

  2. string [][][] aMatrix;

  3. int [][]aInt= new int[3][];

  4. None of the above.

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

Multiple choice technology mainframe
  1. Delimits the PROC control statements

  2. Identifies the control card library

  3. Marks the beginning of one or more program control statements

  4. None of the above

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

Multiple choice technology programming languages
  1. string [,,] aMatrix;

  2. string [][][] aMatrix;

  3. int [][]aInt= new int[3][];

  4. None of the above.

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

Multiple choice technology programming languages
  1. Struct

  2. Delegate

  3. string

  4. Enumeration

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

Multiple choice technology programming languages
  1. The code on line 31 throws an exception

  2. The code on line 33 throws an exception

  3. The code on line 35 throws an exception

  4. The code on line 33 executes successfully

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