All mock tests are FREE till 31 December — register to save your progress
UGC NET · PAPER 2

UGC NET Paper 2 Computer Science – Unit 3: Programming Languages and Computer Graphics PYQ (June 2024 Re-Exam)

14 questions · answer key at the end · updated 11 Oct 2026
Q3. Which of the following statements about pointers in C are TRUE?
(A) Pointers can be used to access array elements
(B) Pointers can store the address of another pointer
(C) Pointers are automatically dereferenced in expressions
(D) Pointers cannot be used to access structure members
Choose the correct answer from the options given below:
  1. (A) and (C) Only
  2. (A) and (B) Only
  3. (B) and (C) Only
  4. (C) and (D) Only
Answer & explanation →
Q6. Consider the function in C code:
Cal(a, b) {
  if (b != 1) {
    if (a != 1) {
      printf("*");
      Cal(a/2, b);
    }
    else {
      b = b - 1;
      Cal(10, b);
    }
  }
}
How many times will * be printed if the function is called with Cal(10, 10)?
  1. 25
  2. 23
  3. 24
  4. 27
Answer & explanation →
Q9. Which of the following is the correct way to declare a function pointer in C?
  1. int *func (int, int);
  2. int (*func) (int, int);
  3. int (func*) (int, int);
  4. int *func* (int, int);
Answer & explanation →
Q12. Consider the following C program:
#include<stdio.h>
int main() {
  int x[] = {2,4,6,8,10};
  int a, b = 0, *y = x + 4;
  for (a = 0; a < 5; a++) {
    b = b + (*y - a) - *(y - a);
  }
  printf("%d\n", b);
  return 0;
}
What will be the output of the above C program?
  1. 4
  2. 6
  3. 8
  4. 10
Answer & explanation →
Q23. Which of the following are TRUE about constructors in C++?
(A) A constructor can be overloaded.
(B) A constructor does not have a return type.
(C) A constructor must be declared as a friend function.
(D) A constructor is called when an object is destroyed.
Choose the correct answer from the options given below:
  1. (B), (C), (D) Only
  2. (B), (C) Only
  3. (A), (B), (C) Only
  4. (A), (B) Only
Answer & explanation →
Q27. What is the output of the following program?
#include<stdio.h>
void f1(char *x, char *y) {
  char *t1;
  t1 = x; x = y; y = t1;
}
void f2(char **x, char **y) {
  char *t1;
  t1 = *x; *x = *y; *y = t1;
}
int main() {
  char *a = "ONE", *b = "TWO";
  f1(a, b);
  printf("%s %s ", a, b);
  f2(&a, &b);
  printf("%s %s", a, b);
  return 0;
}
  1. ONE TWO TWO ONE
  2. TWO ONE ONE TWO
  3. ONE TWO ONE TWO
  4. TWO ONE TWO ONE
Answer & explanation →
Q29. Which of the following C++ statements correctly declares an abstract class?
  1. class A { virtual void show() = 0; };
  2. class A { void show() = 0; };
  3. class A { void show() { }; };
  4. class A { show() = 0; };
Answer & explanation →
Q42. Consider the following C++ program:
#include<iostream>
using namespace std;
void swap(int &x, int &y) {
  int temp = x;
  x = y;
  y = temp;
}
int main() {
  int a = 5, b = 10;
  swap(a, b);
  swap(a, b);
  cout << a << " " << b;
  return 0;
}
What will be the output of the above code?
  1. 5 10
  2. 10 5
  3. 5 5
  4. 10 10
Answer & explanation →
Q48. What is the output of the code given below?
#include<iostream>
using namespace std;
class Base {
public:
  Base() { cout << "Base Const"; }
  virtual ~Base() { cout << "Base dest"; }
};
class Derived : public Base {
public:
  Derived() { cout << "Derived Const"; }
  ~Derived() { cout << "Derived dest"; }
};
int main() {
  Base *b = new Derived();
  delete b;
  return 0;
}
  1. Base Const Derived Const Derived dest Base dest
  2. Base Const Derived Const Base dest Derived dest
  3. Derived Const Base Const Base dest Derived dest
  4. Base Const Derived Const Base dest
Answer & explanation →
Q50. Consider the following C code:
#include<stdio.h>
int temp = 0;
int fun(int x, int y) {
  int z; temp++;
  if (y == 3) return (x*x*x);
  else {
    z = fun(x, y/3);
    return (z*z*z);
  }
}
int main() {
  fun(4, 81);
  printf("%d", temp);
}
What will be the output of the code?
  1. 3
  2. 4
  3. 5
  4. 6
Answer & explanation →
Q52. Match List I with List II
List IList II
(A) HTML(I) Allows for dynamic and interactive web pages.
(B) DHTML(II) Defines the structure of web pages.
(C) XML(III) Object-oriented programming language for web applications.
(D) JAVA(IV) Used for data storage and transport.
  1. (A)-(I), (B)-(III), (C)-(II), (D)-(IV)
  2. (A)-(II), (B)-(III), (C)-(IV), (D)-(I)
  3. (A)-(II), (B)-(I), (C)-(IV), (D)-(III)
  4. (A)-(III), (B)-(I), (C)-(IV), (D)-(II)
Answer & explanation →
Q54. Arrange the following steps of file handling in C in the correct order:
(A) Close the file
(B) Read from or write to the file
(C) Open the file
(D) Check for error
Choose the correct answer from the options given below:
  1. (A), (C), (D), (B)
  2. (D), (B), (C), (A)
  3. (C), (D), (B), (A)
  4. (B), (D), (A), (C)
Answer & explanation →
Q62. What will be the output of the following C code?
#include<stdio.h>
void main() {
  int arr[5] = {10,20,30,40,50};
  int *p = (int*)(&arr + 1);
  printf("%d %d", *(arr+1), *(p-1));
}
  1. 10 50
  2. 20 50
  3. 30 40
  4. 20 40
Answer & explanation →
Q76. Find the output of the following code:
#include<stdio.h>
void main() {
  int arr[] = {1, 2, 3, 4, 5};
  int *p = arr;
  printf("%d", *p++);
  printf("%d", *(p+1));
}
  1. 1, 2
  2. 1, 3
  3. 2, 3
  4. 1, 4
Answer & explanation →

Answer key

  1. 3 – B
  2. 6 – D
  3. 9 – B
  4. 12 – D
  5. 23 – D
  6. 27 – A
  7. 29 – A
  8. 42 – A
  9. 48 – A
  10. 50 – B
  11. 52 – C
  12. 54 – C
  13. 62 – B
  14. 76 – B