All mock tests are FREE till 31 December — register to save your progress
Paper 2 CS · UNIT 03

Programming Languages and Computer Graphics – Previous Year Questions

229 questions from past UGC NET Paper 2 – Computer Science papers, each with the correct answer. Open any question for its explanation.

  1. Which homogeneous 2D matrix transforms the figure (a) on the left side to the figure (b) on the right ?
    Answer: B. [0 −2 6; 1 0 1; 0 0 1] Paper 2 CS · December 2018
  2. Consider the midpoint (Bresenham) algorithm for rasterizing lines: (1) Input (x₁, y₁) and (x₂, y₂) (2) y = y₁ (3) d = f(x₁ + 1, y₁ + 1/2) // f is the implicit form of the line (4) for x = x₁ to x₂ (5) do (6) plot(x, y)…
    Answer: B. P and Q only Paper 2 CS · December 2018
  3. In 3D Graphics, which of the following statements about perspective and parallel projection is/are true? P : In a perspective projection, the farthest an object is from the centre of projection, the smaller it appears.…
    Answer: A. P and Q only Paper 2 CS · December 2018
  4. In 3D Graphics, which of the following statements is/are true? P : Back-face culling is an example of an image- precision visible-surface determination procedure. Q : Z-buffer is a 16-bit, 32-bit, or 64-bit field associ…
    Answer: B. Q only Paper 2 CS · December 2018
  5. Consider the two C++ programs P1 and P2 shown below and two statements about them: S1: P1 prints out 3 S2: P2 prints out 4:2 What can you say about S1 and S2?
    Answer: A. Only S1 is true. Paper 2 CS · December 2018
  6. Consider the following recursive Java function f that takes two long arguments and returns a float value : public static float f(long m, long n) { float result =(float )m/(float )n; if (m<0||n<0) return 0.0f ; else resu…
    Answer: C. 2 Paper 2 CS · December 2018
  7. What does the following Java function perform? (Assume int occupies four bytes of storage) public static int f( int a) { // Pre-conditions : a>0 and no overflow/underflow occurs int b=0 ; for (int i=0; i<32; i++) { b=b<…
    Answer: B. Return the int that has the reversed binary representation of integer a. Paper 2 CS · December 2018
  8. Which of the following HTML5 codes will affect the horizontal as well as vertical alignment of the table content?
    Answer: D. <td style="text-align : center; vertical-align : middle;"> BASH </td> Paper 2 CS · December 2018
  9. Consider the C/C++ function f() given below: void f(char w[]) { int x = strlen(w); // length of the string char c; for (int i = 0; i < x; i++) { c = w[i]; w[i] = w[x − i − 1]; w[x − i − 1] = c; } } Which of the followin…
    Answer: B. It outputs the contents of the array in the original order. Paper 2 CS · December 2018
  10. The definitions in an XML document are said to be __________ when the tagging system and definitions in the DTD are all in compliance.
    Answer: C. valid Paper 2 CS · July 2018
  11. Consider the JavaScript code: var y = "12"; function f() { var y = "6"; alert(this.y); function g() { alert(y); } g(); } f(); If M is the number of alert dialog boxes generated by this code and D1, D2, …, DM are the con…
    Answer: D. M=2; D1 displays ”12”; D2 displays ”6” Paper 2 CS · July 2018
  12. What is the output of the following Java program? class simple { public static void main(String[] args) { simple obj = new simple(); obj.start(); } void start() { long[] P = {3, 4, 5}; long[] Q = method(P); System.out.p…
    Answer: D. 15 : 15 Paper 2 CS · July 2018
  13. What is the output of the following C program? (Assume little-endian representation, with the least significant byte at the lowest address, and a two-byte short int.) #include <stdio.h> int main() { union saving { short…
    Answer: D. 5, 2, 517 Paper 2 CS · July 2018
  14. Given below are three implementations of swap() in C++: (a) void swap(int a, int b) { int temp; temp = a; a = b; b = temp; } called as swap(p, q); (b) void swap(int &a, int &b) { int temp; temp = a; a = b; b = temp; } c…
    Answer: B. (b) only Paper 2 CS · July 2018
  15. In Java, which of the following statements is/are True ? S1 : The ‘final’ keyword applied to a class definition prevents the class from being extended through derivation. S2 : A class can only inherit one class but can…
    Answer: A. S1 and S2 only Paper 2 CS · July 2018
  16. Which of the following statements is/are True ? P : C programming language has a weak type system with static types. Q : Java programming language has a strong type system with static types.
    Answer: C. Both P and Q Paper 2 CS · July 2018
  17. A graphic display system has a frame buffer that is 640 pixels wide, 480 pixels high and 1 bit of color depth. If the access time for each pixel on the average is 200 nanoseconds, then the refresh rate of this frame buf…
    Answer: A. 16 frames per second Paper 2 CS · July 2018
  18. Which of the following statements is/are True regarding the solution to the visibility problem in 3D graphics ? S1 : The Painter’s algorithm sorts polygons by depth and then paints (scan - converts) each Polygon on to t…
    Answer: B. S2 only Paper 2 CS · July 2018
  19. Consider the matrix M = [2 0 2; 0 1 1; 0 0 1] representing a set of planar (2D) geometric transformations in homogeneous coordinates. Which of the following statements about M is true?
    Answer: B. M represents first, a translation of vector (1, 1) followed by scaling of vecto… Paper 2 CS · July 2018