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
  1. HelloHow are you

  2. Hello

  3. It will not compile

  4. It will give exception

  5. None of the above

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

The code will not compile as there is an error in the syntax of foreach loop, there should be foreach (string name in s) instead of foreach (string name: s).

Multiple choice
  1. Method of class AMethod of class B

  2. Method of class BMethod of class B

  3. Method of class AMethod of class A

  4. Compilation error

  5. None of the above

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

The code will not compile as we have an object of type B but base class A does not have the definition of method DemoB of the B class. Hence a.DemoB() is illegal but a.DemoA() is legal.

Multiple choice
  1. Private variable is not accessible in subclass.

  2. There is a syntax error in get property.

  3. It will give exception.

  4. The code will compile with no error.

  5. None of the above

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

Yes, It will compile properly as we get and set the property for the private variable so it is accessible now in subclass too.

Multiple choice
  1. The private modifier can not be used before array declaration.

  2. It will throw an exception.

  3. The static modifier is invalid in the code.

  4. The 'this' keyword is invalid in the code.

  5. No error

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

We can not use static modifier in indexer declaration as static methods can not be used with a particular instance of the class and the indexer uses the instances of the class.

Multiple choice
  1. 0

  2. 20

  3. 40

  4. Compilation error

  5. None of the above

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

It will not compile because there are get and set attribute missed after the indexer's declaration. There should be public abstract int this[int index]{ get; set;} code like to remove this error.

Multiple choice
  1. a=12345 and b=67

  2. a=67 and b=12345

  3. a=12 and b=345

  4. a=12 and b=34567

  5. a=12 and b=67

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

%2d will restrict scanf function to assign only 2 digits in the variable a and rest of the digits will be assigned to the next scanf variable i.e. b.

Multiple choice
  1. Hello

  2. Hi

  3. Error in execution

  4. Normal program execution without any output

  5. Program code error

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

First IF statement is not satisfied  hence,  control will  go to second if,  as it is a statment for first IF and ELSE statement will take priority for second IF which is jumped by control.  Hence,  no output will be coming in print however program will run normally.

Multiple choice
  1. 12

  2. 13

  3. 14

  4. 15

  5. %d

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

x = i > j ? j > k ? 12 : k > l? 13 : 14 : 15; Taking operator precedence, control will start executing from center of the statement. Step I:x = i > j ?( j > k ? 12 : k) > l? 13 : 14 : 15 // Control will get k from here  Step II: Remove the executed part for better understanding x = i > j ? ( k > l? 13 : 14) : 15  // Here value is 14 Step III: x = i > j ? 14 : 15 // i is not greater than j. Hence, 15 will be assigned in int x variable. 

Multiple choice
  1. Yes

  2. Exit from program

  3. Error: exit function should have prototype

  4. No

  5. None of these

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

As input to program is 'n'i.e. other than Y,y, it will exit from program

Multiple choice
  1. 4.000000 4.500000 4.000000 4 0.222222 4

  2. 4 4.500000 4 4.000000 0.222222 4

  3. 4 4.500000 4 4.000000 4 0.222222

  4. 4 4 4 4 4 0.000000

  5. None of these

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

k=9/2.0=4, as k is integer type output will be an integer. j=9.0/2=4.500000, as j is of type float the output will be in float. k=9/2=4, as k is integer type output will be an integer. j=9/2=4.000000 j=2/9.0=0.222222 k=9.0/2.0=4, as k is integer type output will be an integer.

Multiple choice
  1. Counts total number of character in file d.txt

  2. Counts number of blanks in file d.txt

  3. Counts number of tabs in file d.txt

  4. Counts number of lines in file d.txt

  5. Counts total number of characters in file ‘C’ source file

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

The ‘ ‘ counts the blanks in file opened.

Multiple choice
  1. 11

  2. 10

  3. 01

  4. 00

  5. 'If' expression is wrong.

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

a=10,b=12,c=0(!(a>5&&c))=>!(10>5 && 0)=>!(1 &&0)=>!0=>1 If condition is true as we get ‘1’ in above expression.a!=6&&b>5=>10!=6 && 12>5 =>1 && 1 =>1a==10||b<15&&c<1 =>10==10 || 12<15 && 0<1 =>1 || 1 && 1=> 1 So option 1 is correct answer.