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. Compile time error

  2. Run time error

  3. Exception error

  4. JAVA

  5. 0

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

Correct! Because of JVM always execute instruction on the basis of priority so static block has higher priority than main method hence It will execute static block then after it will go to main method (which is essential for all the java programs to run) but here programmer written intelligently his program to get output.

Multiple choice
  1. 0

  2. 1

  3. 2

  4. Compilation fails

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

A default no-args constructor is not created because there is a constructor supplied that has an argument, line 4. Therefore the sub-class constructor must explicitly make a call to the super class constructor:

Multiple choice
  1. The value of i will be 4 and the value of ch will be ’s’.

  2. The value of i will be 3 and the value of ch will be ’h’.

  3. The value of i will be 3 and the value of ch will be ’s’.

  4. The value of i will be 4 and the value of ch will be ’h’.

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

The index of character ‘e’ is 3 because the index is starting from 0. The character at position 5 is ‘h'.

Multiple choice
  1. slip stream

  2. slipstream stream

  3. stream slip stream

  4. slipstream slip stream

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

When the fix() method is first entered, start()'s s1 and fix()'s s1 reference variables both refer to the same String object (with a value of "slip"). Fix()'s s1 is reassigned to a new object that is created when the concatenation occurs (this second String object has a value of "slipstream"). When the program returns to start(), another String object is created, referred to by s2 and with a value of "stream".

Multiple choice
  1. compile time error

  2. run time error

  3. execute successfully with no output

  4. prints In Base Class

  5. none of these

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

When we run stand alone java program, the main method of that class is called. If main method is not present in that class, java runtime system calls the inherited method from parent class.

Multiple choice
  1. parentchild1010

  2. parentchild 2020

  3. child child2020

  4. parentparent 2020

  5. childchild1010

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

par is the object of parent class so it will call meth() method of parent class, par2 will call the mothod of Test1 class due to overriding but the variable will call only of Parent class because overriding is for methods not for variable

Multiple choice
  1. 0 1 2

  2. 1 2 3

  3. 0 1 2 3

  4. Compilation error

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

The code will not compile because the variable counter is an interface variable that is by default final static. The compiler will complain at line 10 when the code attempts to increment counter. So it provides compilation error.

Multiple choice
  1. 57 22

  2. 45 38

  3. 45 57

  4. An exception occurs at runtime

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

You can define an Inner class as abstract, which means you can instantiate only concrete subclasses of the abstract Inner class. The object refered by the variable is an instance of an anonymous subclass of AbstractTest, and the anonymous class overrides the getNum() method to return 22. The variable referenced by f is an instance of an anonymous subclass of Bar, and the anonymous Bar subclass also overrides thegetNum() method (to return 57). Remember that to instantiate a Bar instance, we need an instance of the enclosing AbstractTest class to tie to the new Bar inner class instance. AbstractTest can't be instantiated because it's abstract, so we created an anonymous subclass (non-abstract) and then used the instance of that anonymous subclass to tie to the new Bar subclass instance.

Multiple choice
  1. Because of the Throw portion of exception.

  2. Because of the Catch portion of exception.

  3. Because of the main() portion.

  4. Because of the class portion.

  5. None of the above

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

Though exception is opened and it is generating the exception also but since catch is missing, so the error is not acknowledged and displayed.