Computer Knowledge

Programming Output Evaluation

1,953 Questions

Programming output evaluation tests the ability to trace code execution in languages like C, Java, and SAS. It focuses on arrays, loops, pointers, and data type conversions. These technical questions are standard in computer knowledge sections for IT officer and bank exams.

Java string bufferC language pointersLoop execution outputsData type conversionsMacro variable evaluation

Programming Output Evaluation Questions

Multiple choice technology programming languages
  1. not same

  2. same

  3. unknown symbol ‘~’

  4. none of the above

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

When -1 is assigned to an unsigned int, it wraps around to the maximum value (all bits set to 1). The bitwise NOT of 0 (~0) also produces all bits set to 1. Therefore, both x and y hold the same bit pattern and the comparison 'x == y' evaluates to true, printing 'same'.

Multiple choice technology programming languages
  1. 0001 0002 0003

  2. compile error

  3. 0001 0002 0004

  4. 0001 0002 0006

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

Pointer arithmetic advances by the size of the pointed-to type. char* increments by 1 byte, int* by sizeof(int) (2 bytes on typical 16-bit systems), and long* by sizeof(long) (4 bytes on typical 32-bit systems). Starting from 0, the pointers become 1, 2, and 4 respectively.

Multiple choice technology programming languages
  1. int main()

  2. int main(int argc, char *argv[])

  3. They both work

  4. None of the Above

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

Both int main() and int main(int argc, char *argv[]) are valid main function declarations in C++. The first is for programs without command-line arguments, the second accepts command-line arguments. Both work correctly.

Multiple choice technology programming languages
  1. class aClass{public:int x;};

  2. /* A comment */

  3. char x=12;

  4. None of the Above

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

C does not support classes or the 'class' keyword - these are C++ OOP features. Options B and C are valid C syntax (comments and char initialization). Option A uses C++ class syntax which is invalid in C.

Multiple choice technology programming languages
  1. ab

  2. abc

  3. c

  4. none of the above

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

In the loop initialization, printf("a") executes and prints 'a'. Next, the condition printf("b") executes, prints 'b', and returns a non-zero value (true). The loop body then runs, executing break immediately. The loop terminates before the increment step, resulting in 'ab'.

Multiple choice technology programming languages
  1. 0

  2. 1

  3. compile error

  4. 10

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

Pointer p is assigned address of i. Then p++ increments p by one integer (4 bytes on most systems). The expression (p - &i) calculates the offset between the new pointer address and original address, which is 1 integer - not 1 byte. The difference is measured in the pointer's data type units, so it equals 1.

Multiple choice technology programming languages
  1. 0

  2. 1

  3. compile error

  4. 10

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

A long pointer on most systems is 8 bytes (or 4, depending on architecture), while int is 4 bytes. When you assign &i (int pointer) to long* pointer p, there's a type mismatch. After p++, the difference p - &i is calculated as pointer arithmetic: p advances by sizeof(long) bytes, &i is the original address. The difference is the number of long-sized steps between them, which is 1.