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

Multiple choice technology programming languages
  1. Data Hiding

  2. Encapsulation

  3. Operator Overloading

  4. None Of the Above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The standard C++ input/output streams cin and cout utilize operator overloading. Specifically, the bitwise left shift << and right shift >> operators are overloaded as insertion and extraction operators to perform stream I/O operations.

Multiple choice technology programming languages
  1. two, two, one

  2. two, three, one

  3. two, two, three

  4. two, two, two

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

In SAS macros, &one resolves to 'two' (first PUT). &&one triggers double resolution - it resolves &one to 'two', then resolves &two to 'three' (second PUT). &&&one is triple resolution - &one to 'two', &two to 'three', &three to 'one' (third PUT). The output is: two, two, three. Option C is correct.

Multiple choice technology programming languages
  1. holds the input record for the next INPUT statement to read in the same iteration of the DATA step

  2. holds the input record for the next INPUT statement to read across further iterations of the DATA step

  3. holds the input record for the current input statement to read across further iterations of the DATA step

  4. All of the above

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The single trailing at-sign (@) is a line hold specifier that keeps the input buffer in the current iteration, allowing the next INPUT statement in the same DATA step iteration to continue reading from the same record. It does NOT hold across iterations (that would be double trailing @@). Option A correctly describes this behavior.

Multiple choice technology programming languages
  1. two, two, one

  2. two, three, one

  3. two, two, three

  4. two, two, two

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The first PUT resolves &one normally to 'two'. The double ampersand &&one resolves the first & as a delimiter, triggering another lookup of &one which gives 'two'. The triple &&&one resolves the first two as delimiters, looking up &&one (two), then &one (three). Output: two, two, three.

Multiple choice technology programming languages
  1. holds the input record for the next INPUT statement to read in the same iteration of the DATA step

  2. holds the input record for the next INPUT statement to read across further iterations of the DATA step

  3. holds the input record for the current input statement to read across further iterations of the DATA step

  4. All of the above

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The single trailing @ holds the current input record in the input buffer for the next INPUT statement within the same DATA step iteration. It prevents SAS from moving to a new record until the iteration ends or a double trailing @@ releases it.

Multiple choice technology programming languages
  1. Weight statement

  2. Var statement

  3. Class statement

  4. By statement

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In the PRINT procedure, the VAR statement specifies which variables to include in the output. WEIGHT is used in procedures like PROC MEANS or PROC REG for weighted analysis. CLASS is used for categorical variables in many procedures. BY is for grouping operations. VAR is the correct statement for variable selection in PRINT.

Multiple choice technology programming languages
  1. Prints "ABC" and throws AssertionError

  2. Prints "ABC" and throws AssertionException

  3. Prints "ABC" and exits without any error

  4. Compilation error

  5. Run time exception

  6. None of the above

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The code has a compilation error because the default case uses assert false without a proper expression. In Java, assert requires a boolean expression or a boolean expression with a string message. The syntax assert false: is incomplete.

Multiple choice technology programming languages
  1. 1

  2. two

  3. NumberFormatException

  4. ArrayIndexOutOfBoundsException

  5. Code does not compile

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

args[1] is two, parsing it gives k=2, then args[2] is 3. But Integer.parseInt(args[1]) tries to parse two as an integer, which throws NumberFormatException before any array access happens.

Multiple choice technology programming languages
  1. Compile-time error

  2. Runtime error

  3. No output

  4. None of these

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The code compiles fine since MyThread properly extends Thread. Starting a thread without overriding run() causes it to complete immediately with no output. Thread's default run() is empty.

Multiple choice technology programming languages
  1. n = n->next; free( n );

  2. struct node m = n; n = n->next; free( m );

  3. free( n ); n = n->next;

  4. struct node m = n; free( m ); n = n->next;

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

To free a linked list, you must save the next pointer BEFORE freeing the current node, then advance. Option B: 'struct node m = n; n = n->next; free(m);' correctly copies the pointer, advances n to next, then frees the original node. Option A frees next instead of current (memory leak), Option C frees before reading next (use-after-free crash), Option D frees before advancing (memory leak).