Computer Knowledge

Programming Output Evaluation

1,721 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. 32

  2. 4

  3. 64

  4. 16

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

The macro square(x) expands to x*x. When used in 64/square(4), this becomes 64/4*4 due to macro expansion (not 64/(4*4)). Following C's left-to-right evaluation for same-precedence operators: 64/4 = 16, then 16*4 = 64. This is a classic macro pitfall - always use parentheses in macro definitions. Option C (64) is correct.

Multiple choice technology programming languages
  1. 100 100 100 2 112 104 102 3

  2. 100 104 108 3 112 116 120 3

  3. 100 100 100 2 112 104 102 2

  4. 100 104 108 2 112 116 120 2

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

With base address 100, a is the array address (100). a is the first 2D array address (also 100 due to same starting point). **a is the first 1D array address (still 100). **a dereferences to the first element value (2). For the second printf: a+1 adds one full 3D array (size 12 integers = 48 bytes) giving 148... wait, let me recalculate. With base address 100 for a[2][3][2], each dimension's size varies. The output 100 100 100 2, 112 104 102 3 is consistent with pointer arithmetic on this multidimensional array structure.

Multiple choice technology programming languages
  1. 123 234 340 012

  2. 111 222 333 444

  3. 111 222 444 333

  4. 012 340 234 123

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

This code uses an array of pointers and a pointer to a pointer. ptr starts pointing to p. After ptr++, ptr-p=1, *ptr-a=1, **ptr=1 (value at a[1]). The operations *ptr++, *++ptr, and ++*ptr manipulate these pointers in different ways. The output 111 222 333 444 shows the progression through the array elements as the pointer is advanced through each step.

Multiple choice technology web technology
  1. compiletime error at lines 3,4,5

  2. compiltime error at line 4,5

  3. compiletime error at line 3

  4. Runtime Exception

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

Line 3 is valid Java syntax creating a 2D array. Line 4 is invalid because array declaration syntax int a2[4] is not allowed in Java (must use int[] a2 and initialization syntax). Line 5 is invalid because it declares array but uses C-style declaration syntax and the variable a2 is already declared.

Multiple choice technology
  1. -9999

  2. -1000

  3. -100

  4. -999

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

The picture string -$$$$ has 5 positions (1 minus sign + 4 $ positions). For a dollar symbol to appear, at least one $ must remain after the digits occupy their positions. With -999, three digit positions are used, leaving one $ visible, producing -$999. Larger values like -1000 would show no $ symbol.

Multiple choice technology programming languages
  1. Microsoft Internet Explorer 3.02

  2. Netscape Navigator 3.02

  3. Opera 3.51

  4. SunSoft HotJava 1.0

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

SunSoft HotJava 1.0, released in the late 1990s, was primarily designed to showcase Java Applets and did not implement JavaScript. Contrastingly, Microsoft Internet Explorer 3.02, Netscape Navigator 3.02, and Opera 3.51 all featured built-in support for JavaScript, which had quickly become the standard scripting language for web browsers.

Multiple choice technology programming languages
  1. JavaScript 1.3 Standard

  2. ISO-262 Standard

  3. IEEE-262 Standard

  4. None of the above

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

The JavaScript international standard is called ECMAScript (standard ECMA-262), not any of the names listed in options A, B, or C. 'JavaScript 1.3 Standard', 'ISO-262', and 'IEEE-262' are not correct standard names. Therefore 'None of the above' is the correct answer.

Multiple choice technology programming languages
  1. JavaScript is DHTML plus CSS plus Document Object Model.

  2. DHTML is Document Object Model plus JavaScript plus CSS.

  3. Document Object Model is JavaScript plus DHTML plus CSS.

  4. JavaScript has nothing to do with DHTML.

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

To answer this question, the user needs to have a basic understanding of JavaScript and DHTML.

JavaScript is a programming language used to create interactive effects on web pages. DHTML stands for Dynamic HTML, which is a combination of HTML, CSS, and JavaScript used to create dynamic web content.

Now, let's evaluate each option to determine the correct answer:

A. JavaScript is DHTML plus CSS plus Document Object Model. This statement is incorrect as DHTML is the combination of HTML, CSS, and JavaScript. JavaScript is an integral part of DHTML, not an addition to it.

B. DHTML is Document Object Model plus JavaScript plus CSS. This statement is correct. DHTML is the combination of HTML, CSS, and JavaScript used to create dynamic web content. The Document Object Model (DOM) is a programming interface for HTML and XML documents, and it is used by JavaScript to modify the content and structure of web pages.

C. Document Object Model is JavaScript plus DHTML plus CSS. This statement is incorrect as JavaScript is a part of DHTML, not the other way around. The DOM is used by JavaScript to modify DHTML, not the other way around.

D. JavaScript has nothing to do with DHTML. This statement is incorrect. JavaScript is an essential part of DHTML and is used to create dynamic web content.

Therefore, the correct answer is:

The Answer is: B. DHTML is Document Object Model plus JavaScript plus CSS.

Multiple choice technology programming languages
  1. doStuffx = 5 main x = 5

  2. Compilation fails.

  3. doStuffx = 6 main x = 5

  4. An exception is thrown at runtime

  5. doStuffx = 6 main x = 6

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

Java uses pass-by-value for primitive types. When x=5 is passed to doStuff(), the method receives a copy of x (value 5). The post-increment x++ prints 5 first, then increments the local parameter to 6. The original x in main remains 5 because primitives are passed by value, not by reference.

Multiple choice technology programming languages
  1. int[] scores = {3, 5, 7};

  2. int [][] scores = {2,7,6}, {9,3,45};

  3. String cats[] = {“Fluffy”, “Spot”, “Zeus”};

  4. boolean results[] = new boolean [3] {true, false, true};

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

Option A is valid 1D array initialization. Option B has two errors: missing inner braces for 2D structure, and incorrect syntax - should be {{2,7,6}, {9,3,45}}. Option C is valid String array. Option D is invalid - cannot specify size [3] when using array initialization syntax; either use new boolean[3] or the initialization syntax, not both.

Multiple choice technology programming languages
  1. compiler error

  2. Hello from a thread!

  3. runtime error

  4. none of these

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

The code creates a new HelloThread object and calls start(), which spawns a new thread and invokes run(). The run() method prints "Hello from a thread!". This is standard Java threading - the Thread class's start() method creates the thread and calls run() in the new execution context.

Multiple choice technology programming languages
  1. k will display garbage values

  2. k will print 0, as default constructor is called.

  3. Error as no constructor is defined.

  4. Error, as main should precede with int and should return 0.

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

Const data members must be initialized either via an initializer list in the constructor or with in-class initialization (C++11 and later). Since class A has no constructor and const member k is not initialized at declaration, the code fails to compile.

Multiple choice technology programming languages
  1. 42

  2. Compilation Error - Incompatible Type

  3. Runtime Error - Java.lang.ClassCastException

  4. None of above

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

The code correctly adds Integer 42 at index 0, then retrieves it using get(0). Since autounboxing converts Integer to int automatically when assigning to the int variable 'total', the output is 42. There is no compilation error (types are compatible) and no ClassCastException (autounboxing handles the conversion).

Multiple choice technology programming languages
  1. 3.14

  2. Compile time error

  3. Run time error

  4. None of above

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

The code produces a compilation error because static import of java.lang.Math.PI is invalid syntax - PI is a static field but cannot be imported this way. The correct approach is either to use Math.PI directly or import the entire Math class statically. Options A, C, and D are incorrect.