C Programming Question Paper GATE PSU

C Programming Question Paper-GATE & PSU Exam

Last updated on March 20th, 2025 at 02:47 am

Here, We will see the C Programming Question Paper from the previous year’s exam and the syllabus of C Programming for the GATE and PSU Exam.

1. C Programming in Gate CSE Exam

C Programming is a cornerstone of the GATE Computer Science and Information Technology (CS/IT) exam, testing candidates’ understanding of fundamental concepts like pointers, memory management, data structures, and function behavior. These questions evaluate problem-solving skills and technical proficiency, making them critical for securing high scores.

2. C Programming Syllabus

The C Programming Questions asked in the GATE and PSU Exam focused on topics:

  1. Pointer Operations: Manipulating pointers, array-pointer relationships, and dynamic memory allocation (e.g., malloc and free).
  2. Data Structures: Declarations involving structures, unions, and linked lists.
  3. Function Behavior: Analyzing parameter passing (call-by-value vs. call-by-reference) and recursion, including stack activation records and scope rules.
  4. Memory Management: Calculating memory requirements for variables, considering alignment and union sizes.

Q. What is the value of f(4) using the following C code:

int f(int k) {
  if (k < 3)
    return k;
  else
    return f(k - 1) * f(k - 2) + f(k - 3);
}
  1. 5
  2. 6
  3. 7
  4. 8
Answer

5
NIELIT 2021 Dec Scientist B

Q. Bug means

  1. A logical error in a program
  2. A difficult syntax error in a program
  3. Documenting programs using an efficient documentation tool
  4. All of the above
Answer

A logical error in a program
NIELIT 2017 July Scientist B (CS)

Q. What does the following code do

int a, b;
a = a + b;
b = a – b;
a = a – b;
  1. leaves a and b unchanged
  2. a doubles and stores in a
  3. b doubles and stores in a
  4. Exchanges a and b
Answer

Exchanges a and b
NIELIT 2021 Dec Scientist B

Q. The following program is to be tested for statement coverage:

begin
if (a == b) {
  S1;
  exit;
} else if (c == d) {
  S2;
} else {
  S3;
  exit;
}
S4;
end

The test cases T1,T2,T3 and T4 given below are expressed in terms of the properties satisfied by the values of variables a,b,c and d. The exact values are not given.
T1 : a,b,c and d are all equal
T2 : a,b,c and d are all distinct
T3 : a=b and c!=d
T4 : a!=b and c=d
Which of the test suites given below ensures coverage of statements S1,S2,S3 and S4?

  1. T1,T2,T3
  2. T2,T4
  3. T3,T4
  4. T1,T2,T4
Answer

T1,T2,T4
NIELIT 2017 July Scientist B (IT)

Q. Following are implicitly provided in C programming language :

  1. Output facility
  2. Input facility
  3. Both Input and Output facility
  4. No Input and Output facility
Answer

Both Input and Output facility
NIELIT 2021 Dec Scientist B

Q. Consider the following C declaration

struct {
  short s[5];
  union {
    float y;
    long z;
  }
  u;
}
t;

Assume that objects of the type short, float and long occupy 2 bytes, 4 bytes and 8 bytes respectively. The memory requirement for variable t ignoring alignment considerations, is

  1. 22 bytes
  2. 14 bytes
  3. 18 bytes
  4. 10 bytes
Answer

18 bytes
NIELIT 2017 July Scientist B (IT)

Q. _________ is the elapsed time between the time a program or job is submitted and the time when it is completed.

  1. Response time
  2. Turnaround time
  3. Waiting time
  4. Throughput
Answer

Turnaround time
NIELIT 2021 Dec Scientist B

Q. Control structures include

  1. iteration
  2. rendezvous statements
  3. exception statements
  4. all of these
Answer

all of these
NIELIT 2016 MAR Scientist B

Q. A variable p is said to be a line at point m if and only if :

  1. p is assigned at point m
  2. p is not assigned at point m
  3. Value of p at m would be used along some path in the flow graph starting at point m
  4. Value of p at m would be used along some path in the flow graph ending at point m
Answer

Value of p at m would be used along some path in the flow graph starting at point m
NIELIT 2021 Dec Scientist B

Q. What is the meaning of following declaration?

int(*p[7])();
  1. p is pointer to function
  2. p is pointer to such function which return type is array
  3. p is array of pointer to function
  4. p is pointer to array of function
Answer

p is array of pointer to function
NIELIT 2016 DEC Scientist B (IT)

Q. Which of the following is illegal declaration in language?

  1. char*str =”Raj is a Research scholar”;
  2. char str[25] =”Raj is a Research scholar”;
  3. char str[40] =”Raj is a Research scholar”;
  4. char[]str =”Raj is a Research scholar”;
Answer

char[]str =”Raj is a Research scholar”;
NIELIT 2017 DEC Scientific Assistant A

Q. If x is a one-dimensional array, then

  1. *(x+i) is same as *(&x[i])
  2. &x[i] is same as x+i-1
  3. *(x+i) is same as *x[i]
  4. *(x+i) is same as *x+i
Answer

*(x+i) is same as *(&x[i])
NIELIT 2017 DEC Scientist B

Q. Assume that float takes 4 bytes, and predict the output of following program.

#include<stdio.h>

int main() {
  float arr[5] = {12.5,10.0,13.5,90.5,0.5};
  float * ptr1 = & arr[0];
  float * ptr2 = ptr1 + 3;
  printf("%f", * ptr2);
  printf("%d", ptr2 - ptr1);
  return 0;
}
  1. 90.500000 3
  2. 90.500000 12
  3. 10.000000 12
  4. 0.500000 3
Answer

90.500000 3
NIELIT 2017 July Scientist B (IT)

Q. Given the following characteristics :
i. Optimal substructure
ii. Overlapping subproblems
iii. Memorization
iv. Decrease and conquer
Dynamic programming has the following characteristics:

  1. i,ii,iv
  2. i,ii,iii
  3. ii,iii,iv
  4. i,iii,iv
Answer

i,ii,iii
NIELIT 2021 Dec Scientist A

Q. ______ is used to convert from recursive to iterative implementation of an algorithm.

  1. Array
  2. Tree
  3. Stack
  4. Queue
Answer

Stack
NIELIT 2018

Q. How will you free the allocated memory?

  1. remove(var-name)
  2. free(var-name)
  3. delete(var-name)
  4. dalloc(var-name)
Answer

free(var-name)
NIELIT 2016 DEC Scientist B (IT)

Q. What does the following C-statement declare?

int (*f) (int * );
  1. A function that takes an integer pointer as an argument and returns an integer.
  2. A function that takes an integer as an argument and returns an integer pointer.
  3. A pointer to a function that takes an integer pointer as an argument and returns an integer.
  4. A function that takes an integer pointer as an argument and returns a function pointer.
Answer

A pointer to a function that takes an integer pointer as argument and returns an integer.
NIELIT 2022 April Scientist B

Q. The keyboard used to transfer control from a function back to the calling function is:

  1. switch
  2. go to
  3. go back
  4. return
Answer

return
NIELIT 2016 DEC Scientist B (IT)

Q. What will be the output if you will compile and execute the following C code?

void main() {
  printf("%d", sizeof(5.2));
}
  1. 4
  2. 8
  3. 2
  4. 16
Answer

8
NIELIT 2016 DEC Scientist B (CS)

Q. What will be output if you will compile and execute the following C code?

void main() {
  char c = 125;
  c = c + 10;
  printf("%d", c);
}
  1. 135
  2. 115
  3. -121
  4. -8
Answer

-121
NIELIT 2016 DEC Scientist B (CS)

Q. Consider the following C code:

#include<stdio.h>

int * assignval(int * x, int val) {
  * x = val;
  return x;
}
int main() {
  int * x = malloc(sizeof(int));
  if (NULL == x) return;
  x = assignval(x, 0);
  if (x) {
    x = (int * ) malloc(sizeof(int));
    if (NULL == x) return;
    x = assignval(x, 10);
  }
  printf("%d\n", * x);
  free(x);
}

The code suffers from one of the following problems:

  1. compiler error as the return of malloc is not typecast appropriately.
  2. compiler error because the comparison should be made as x==NULL and not as shown.
  3. compiles successfully but execution may result in the dangling pointer.
  4. compiles successfully but execution may result in a memory leak
Answer

compiles successfully but execution may result in memory leak
NIELIT 2022 April Scientist B

Q. Output of the following loop is

for (putchar('c'); putchar('a'); putchar('r'))
  putchar('t');
  1. a syntax error.
  2. cartrt.
  3. catrat.
  4. catratratratrat…
Answer

catratratratrat…
NIELIT 2016 MAR Scientist B

Q. Output of following program

#include<stdio.h>

int main() {
  int i = 5;
  printf("%d %d %d", i++, i++, i++);
  return 0;
}
  1. 7 6 5
  2. 5 6 7
  3. 7 7 7
  4. Compiler Dependent
Answer

Compiler Dependent
NIELIT 2017 July Scientist B (IT)

Q. Output of following program?

#include<stdio.h>

void dynamic(int s, …) {
  printf("%d", s);
}
int main() {
  dynamic(2, 4, 6, 8);
  dynamic(3, 6, 9);
  return 0;
}
  1. 2 3
  2. Compiler Error
  3. 4 3
  4. 3 2
Answer

2 3
NIELIT 2017 July Scientist B (IT)

Q. Assume that size of an integer is 32 bit. What is the output of following ANSI C program?

#include<stdio.h>

struct st {
  int x;
  static int y;
};
int main() {
    printf( % d ",sizeof(struct st));
      return 0;
    }
  1. 4
  2. 8
  3. Compiler Error
  4. Runtime Error
Answer

Compiler Error
NIELIT 2017 July Scientist B (IT)

Q. What is printed by the print statements in the program P1 assuming call by reference parameter passing ?

Program P1() {
  x = 10;
  y = 3;
  func1(y, x, x);
  print x;
  print y;
}
func1(x, y, z) {
  y = y + 4;
  z = x + y + z;
}
  1. 10,3
  2. 31,3
  3. 27,7
  4. 33,5
Answer

27,7
NIELIT 2022 April Scientist B

Q. Consider these two functions and two statements S1 and S2 about them.

int work1(int *a, int i, int j)
{
int x = a[i+2];
a[j] = x+1;
return a[i+2] – 3;
}
int work2(int *a, int i, int j)
{
int t1 = i+2;
int t2 = a[t1];
a[ j] = t2+1;
return t2 – 3;
}

S1 : The transformation form work1 to work2 is valid, i.e., for any program state and input arguments, work2 will compute the same output and have the same effect on program state as work1.
S2 : All the transformations applied to work1 to get work2 will always improve the performance (i.e reduce CPU time) of work2 compared to work1.

  1. S1 is false and S2 is false
  2. S1 is false and S2 is true
  3. S1 is true and S2 is false
  4. S1 is true and S2 is true
Answer

S1 is false and S2 is false
NIELIT 2022 April Scientist B

Q. Output of the following program?

#include<stdio.h>

struct st {
  int x;
  struct st next;
};
int main() {
  struct st temp;
  temp.x = 10;
  temp.next = temp;
  printf("%d", temp.next, x);
  return 0;
}
  1. Compiler Error
  2. 10
  3. Runtime Error
  4. Garbage Value
Answer

Compiler Error
NIELIT 2017 July Scientist B (IT)

Q. If a++ is replaced with ++a, which statement does not get affected?

  1. printf(“% d % d”, ++a, a++);
  2. a = 20; a++;
  3. while(a++ = 20) cout<<a;
  4. d = a++;
Answer

d = a++;
NIELIT 2021 Dec Scientist B

Q. Choose correct statement for code segment

int multiply (int a, int b = 5),
  1. variable a and b are of types and the initial value of a and b are 5
  2. variable b is of type and will always have value 5
  3. variable b is of global scope and will have value 5
  4. variable b will have value 5 if not specified when calling a function in further program
Answer

variable b will have value 5 if not specified when calling a function in further program
NIELIT 2021 Dec Scientist B

Q. The question is based on the following program fragment.

f(intY[10], int x) {
  int u, j, k;
  i = 0;
  j = 9;
  do {
    k = (i + j) / 2;
    if (Y[k] < x) i = k;
    else j = k;
  } while (Y[k] != x) && (i < j));
if (Y[k] == x) printf(“x is in the array.”);
else printf(“x is not in the array.”);
}

On which of the following contents of ‘Y’ and ‘x’ does the program fail?

  1. Y is [1 2 3 4 5 6 7 8 9 10] and x<10
  2. Y is [1 3 5 7 9 11 13 15 17 19] and x<1
  3. Y is [2 2 2 2 2 2 2 2 2 2] and x>2
  4. Y is [2 4 6 8 10 12 14 16 18 20] and 2<x<20 and ‘x’ is even
Answer

Y is [2 2 2 2 2 2 2 2 2 2] and x>2
NIELIT 2017 OCT Scientific Assistant A (CS)

Q. What will be the output of following?

main() {
  Static int a = 3;
  Printf(“ % d”, a--);
  If(a)
  main();
}
  1. 3
  2. 3 2 1
  3. 3 3 3
  4. Program will fall in continuous loop and print 3
Answer

3 2 1
NIELIT 2017 OCT Scientific Assistant A (CS)

Q. The following program fragment prints

int i = 5;
do {
  putchar(i + 100);
  printf(“ % d”, i--;)
}
while (i);
  1. i5h4g3f2el
  2. 14h3g2f1e0
  3. An error message
  4. None of the above
Answer

i5h4g3f2el
NIELIT 2017 OCT Scientific Assistant A (CS)

Q. Which of the following operators cannot be overloaded?

  1. ++
  2. ::
  3. ~
  4. ()
Answer

::
NIELIT 2021 Dec Scientist B

Q. The number of swaps required to sort the array
8,22,7,9,31,19,5,13
In ascending order using bubble sort is :

  1. 10
  2. 9
  3. 13
  4. 14
Answer

10
NIELIT 2021 Dec Scientist B

Q. Prior to using a pointer variable it should be

  1. declared.
  2. initialized.
  3. both declared and initialized.
  4. none of these.
Answer

both declared and initialized.
NIELIT 2016 MAR Scientist B

Q. The number of tokens in the following C statement is

printf("i=%d, &i=%x", i, &i);
  1. 8
  2. 4
  3. 7
  4. 10
Answer

10
NIELIT Scientist B 2020 November

Q. Output of following program?

#include<stdio.h>

int main() {
    int * ptr;
    int x;
    ptr = & x;
    * ptr = 0;
    printf("x=%d\n", x);
    printf("ptr=%d\n", ptr);
    ptr += 5;
    printf("x=%d\n", x);
    printf("ptr=%d\n", ptr);
    (ptr) ++;
    printf(“x = % d\ n ",x);
      printf("ptr=%d\n", ptr);
      return 0;
    }
  1. x=0
    *ptr=0
    x=5
    *ptr=5
    x=6
    *ptr=6
  2. x=garbage value
    *ptr=0
    x=garbage value
    *ptr=5
    x=garbage value
    *ptr=6
  3. x=0
    *ptr=0
    x=5
    *ptr=5
    x=garbage value
    *ptr=garbage value
  4. x=0
    *ptr=0
    x=0
    *ptr=0
    x=0
    *ptr=0
Answer

x=0
*ptr=0
x=5
*ptr=5
x=6
*ptr=6

NIELIT 2017 July Scientist B (IT)

Q. Debugger is a program that:

  1. Allows to examine and modify the contents of registers
  2. Allows to set breakpoints, execute a segment of program and display contents of register
  3. Does not allow execution of a segment of program
  4. All the options
Answer

Allows to set breakpoints, execute a segment of program and display contents of register
NIELIT Scientist B 2020 November

Q. In C language value of ix+j, if j is of integer type and ix long type would be:

  1. Integer
  2. Float
  3. Long integer
  4. Double precision
Answer

Long integer
NIELIT 2021 Dec Scientist B

Q. Consider the following two functions.

void fun1(int n) {
  if (n == 0) return;
  printf("%d", n);
  fun2(n - 2);
  printf("%d", n);
}
void fun2(int n) {
  if (n == 0) return;
  printf("%d", n);
  fun1(++n);
  printf("%d", n);
}

The output printed when fun195) is called is

  1. 53423122233445
  2. 53423120112233
  3. 53423122132435
  4. 53423120213243
Answer

53423122132435
NIELIT 2022 April Scientist B

Q. Consider the following declaration.

int a, *b = &a, **c = &b;
a = 4;
**c = 5;

If the statement

b = (int *)**c

Is appended to the above program fragment then

  1. Value of b becomes 5
  2. Value of b will be the address of c
  3. Value of b is unaffected
  4. None of these
Answer

Value of b becomes 5
NIELIT 2017 OCT Scientific Assistant A (IT)

Q. The best statement to find out that value of a variable lies in the range 7 to 10 or 12 to 15 in language is :

  1. switch
  2. while
  3. for
  4. continue
Answer

switch
NIELIT 2021 Dec Scientist B

Q. The maximum combined length of the command-line arguments including the spaces between adjacent arguments is:

  1. 128 characters
  2. 256 characters
  3. 67 characters
  4. It may very from one Operating System to another
Answer

It may very from one Operating System to another
NIELIT 2016 DEC Scientist B (IT)

Q. What is the correct way to round off x, a float to an int value?

  1. y = (int)(x+0.5)
  2. y = int(x+0.5)
  3. y = (int)x+0.5
  4. y = (int)(int)x+0.5
Answer

y = (int)(x+0.5)
NIELIT 2016 MAR Scientist B

Q. What error would the following function give on compilation?

f(int a, int b) {
  int a;
  a = 20;
  return a;
}
  1. Missing parenthesis is return statement.
  2. Function should be defined as int f(int a, int b)
  3. Redeclaration of a.
  4. None of these.
Answer

Redeclaration of a.
NIELIT 2016 MAR Scientist B

Q. Output of following code

main() {
  printf("\n%%%%");
}
  1. Error message
  2. %%
  3. 00
  4. &&&&
Answer

%%
NIELIT 2021 Dec Scientist B

Q. Consider the following C function :

int f(int n) {
  static int i = 1;
  if (n > = 5) return n;
  n = n + i;
  i++;
  return f(n);
}

The value returned by f(1) is :

  1. 5
  2. 6
  3. 7
  4. 8
Answer

7
NIELIT 2021 Dec Scientist B

Q. If space occupied by two strings s1 and s2 in ‘C’ are respectively m and n, then space occupied by string obtained by concatenating s1 and s2 is always

  1. less than m+n
  2. equal to m+n
  3. greater than m+n
  4. none of these
Answer

less than m+n
NIELIT 2016 MAR Scientist B

Q. An external variable

  1. is globally accessible by all functions
  2. has a declaration “extern” associated with it when declared within a function
  3. will be initialized to 0 if not initialized
  4. all of these
Answer

all of these
NIELIT 2016 MAR Scientist C

Q. If initialization is a part of declaration of a structure, then storage class can be

  1. automatic
  2. register
  3. static
  4. anything
Answer

static
NIELIT 2016 MAR Scientist C

Q. For x and y are variables as declared below double x=0.005, y=-0.01; What is the value of ceil (x+y), where ceil is a function to compute ceiling of a number?

  1. 1
  2. 0
  3. 0.005
  4. 0.5
Answer

0
NIELIT 2016 MAR Scientist C

Q. In C programming language, if the first and the second operands of operator + are of types int and float, respectively, the result will be of type

  1. int
  2. float
  3. char
  4. long int
Answer

float
NIELIT 2016 MAR Scientist C

Q. What will be the value of x and y after execution of the following statement(C language)

n = 5;
x = n++;
y = -x;
  1. 5,-4
  2. 6,-5
  3. 6,-6
  4. 5,-5
Answer

5,-5
NIELIT 2016 MAR Scientist C

Q. What will be the output of the following C program?

void count(int n) {
  static int d = 1;
  printf(" %d", n);
  printf(" %d", d);
  d++;
  if (n > 1) count(n - 1);
  printf(" %d", d);
}
void main() {
  count(3);
}
  1. 3 1 2 2 1 3 4 4 4
  2. 3 1 2 1 1 1 2 2 2
  3. 3 1 2 2 1 3 4
  4. 3 1 2 1 1 1 2
Answer

3 1 2 2 1 3 4 4 4
NIELIT 2021 Dec Scientist B

Q. Following is C like Pseudo code of a function that takes a number as an argument, and uses a stack S to do processing.

void fun(int n) {
  Stack S; //Say it creates an empty stack S while(n>0)
  {
    // This line pushes the value of n%2 to stack S;
    Push( & S, n % 2);
    n = n / 2;
  }
  // Run while Stack S is not empty while(!is Empty(&S))
  printf("%d", pop( & S)); //pop an element from S and print it
}

What does the above function do in general?

  1. Prints binary representation of n in reverse order.
  2. Prints binary representation of n.
  3. Prints the value of logn.
  4. Prints the value of logn in reverse order
Answer

Prints binary representation of n.
NIELIT 2017 July Scientist B (CS)

Q. Which of the following object types are generally autonomous, meaning that they can exhibit some behavior without being operated upon by another object?

  1. Passive
  2. Active
  3. Both (A) and (B)
  4. None of the mentioned
Answer

Active
NIELIT 2017 OCT Scientific Assistant A (IT)

Q. The IOS class member function used for formatting IO is

  1. width(), precision(), read()
  2. width(), precision(), setf()
  3. getch(), width(), Io()
  4. unsetf() ,setf(), write()
Answer

width(), precision(), setf()
NIELIT 2016 DEC Scientist B (CS)

Q. Which of the following is not an input device?

  1. Mouse
  2. Keyboard
  3. Light Pen
  4. VDU
Answer

VDU
NIELIT 2016 DEC Scientist B (IT)

Q. Given a class named student, which of the following is a valid constructor declaration for the class?

  1. Student student(){}
  2. Private final student(){}
  3. Student(student s){}
  4. Void student(){}
Answer

Student(student s){}
NIELIT 2016 DEC Scientist B (IT)

Q. An operation can be described as:

  1. Object behavior
  2. Functions
  3. Class behavior
  4. Both (A) and (B)
Answer

Both (A) and (B)
NIELIT 2016 DEC Scientist B (IT)

Q. Which one of the following cannot be scheduled by the kernel?

  1. Kernel level thread
  2. User level thread
  3. Process
  4. None of the option
Answer

User level thread
NIELIT 2021 Dec Scientist A

Q. An object can have which of the following multiplicities?

  1. Zero
  2. More than one
  3. One
  4. All of the above
Answer

All of the above
NIELIT 2016 DEC Scientist B (IT)

Q. Earlier name of Java programming language was:

  1. OAK
  2. D
  3. Netbean
  4. Eclipse
Answer

OAK
NIELIT 2016 DEC Scientist B (IT)

Q. Which of the following is a platform-free language?

  1. JAVA
  2. C
  3. Assembly
  4. Fortran
Answer

JAVA
NIELIT 2016 DEC Scientist B (IT)

Q. Object-oriented inheritance models:

  1. “is a kind of” relationship.
  2. “has a” relationship.
  3. “want to be” relationship.
  4. “contains” of relationship.
Answer

“is a kind of” relationship.
NIELIT 2016 DEC Scientist B (IT)

Q. Consider the following Syntax Directed Translation Scheme (SDTS), with non-terminals {S,A} and terminals {a,b}.
• S → aA {print 1}
• S → a {print 2}
• A → Sb {print 3}
Using the above SDTS, the output printed by a bottom-up parser, for the input aab is:

  1. 1 3 2
  2. 2 2 3
  3. 2 3 1
  4. Syntax Error
Answer

2 3 1
NIELIT 2022 April Scientist B

Q. Give the output

#include<iostream>

using namespace std;
class Base {
  public: int x,
  y;
  public: Base(int i, int j) {
    x = i;
    y = j;
  }
};
class Derived: public Base {
  public: Derived(int i, int j): x(i),
  y(j) {}
  void print() {
    cout << x << "" << y;
  }
};
int main(void) {
  Derived q(10, 10);
  q.print();
  return 0;
}
  1. 10 10
  2. Compiler Error
  3. 0 0
  4. None of the option
Answer

Compiler Error
NIELIT 2017 July Scientist B (IT)

Q. What is the output of the following program?

abstract class sum {
  public abstract int sumOfTwo(int n1, int n2);
  public abstract int sumOfThree(int n1, int n2, int n3);
  public void disp() {
    System.out.println("Method of class Sum");
  }
}
class DemoAbstract1 extends Sum {
  public int sumOfTwo(int num1, int num2) {
    return num1 + num2;
  }
  public int sumOfThree(int num1, int num2, int num3) {
    return num1 + num2 + num3;
  }
  public static void main(String args # # # Q.]) {
  Sum obj = new DemoAbstract1();
  System.out.println(obj.sumOfTwo(3, 7));
  System.out.println(obj.sumOfThree(4, 3, 19));
  obj.disp();
}
}
  1. 10
    26
    Method of class Sum
  2. 26
    10
    Method of class Sum
  3. Method of class Sum
    26
    10
  4. Error
Answer

10
26
Method of class Sum

NIELIT Scientific Assistant A 2020 November

Q. The static keyword is used in public static void main() declaration in Java:

  1. To enable the JVM to make call to the main(), as class has not been instantiated
  2. To enable the JVM to make call to the main(), as class has not been inherited
  3. To enable the JVM to make call to the main(), as class has not been loaded
  4. To enable the JVM to make call to the main(), as class has not been finalized
Answer

To enable the JVM to make call to the main(), as class has not been instantiated
NIELIT Scientific Assistant A 2020 November

Q. Match the following in from List-1 and List-2 :

List-1List-2
(a). Create new classes from existing class(i). Polymorphism
(b). Using similar operations to do similar things(ii). Abstraction
(c). Hiding implementation details(iii). Inheritance
(d). Wrapping both operator and attributes with operations for model object(iv). Encapsulation
(v). Performance
  1. (a)-(iii), (b)-(i), (c)-(ii), (d)-(iv)
  2. (a)-(v), (b)-(i), (c)-(iii), (d)-(ii)
  3. (a)-(ii), (b)-(v), (c)-(iv), (d)-(iii)
  4. (a)-(i), (b)-(ii), (c)-(iii), (d)-(iv)
Answer

(a)-(iii), (b)-(i), (c)-(ii), (d)-(iv)
NIELIT 2021 Dec Scientist B

Q. Which of the following is true about interfaces in Java?
1. An interface can contain following type of members….public, static, final fields(i.e., constants)… default and static methods with bodies.
2. An instance of interface can be created.
3. A class can implement multiple interfaces.
4. Many classes can implement the same interface.

  1. 1,3 and 4
  2. 1,2 and 4
  3. 2,3 and 4
  4. 1,2,3 and 4
Answer

1,3 and 4
NIELIT 2017 July Scientist B (IT)

Q. Which one of the following contains date information?

  1. java.sql.TimeStamp
  2. java.sql.Time
  3. java.io.Time
  4. java.io.TimeStamp
Answer

java.sql.TimeStamp
NIELIT 2021 Dec Scientist B

Q. Is null an object?

  1. Yes
  2. No
  3. Sometimes yes
  4. None of these
Answer

No
NIELIT 2017 OCT Scientific Assistant A (IT)

Q. Give the output

#include<iostream>

using namespace std;
class Base1 {
  public:
    ~Base1() {
      cout << "Base1's destructor" << endl;
    }
};
class Base2 {
  public:
    ~Base2() {
      cout << "Base2's destructor" << endl;
    }
};
class Derived: public Base1, public Base2 {
  public:
    ~Derived() {
      cout << "Derived's destructor" << endl;
    }
};
int main() {
  Derived d;
  return 0;
}
  1. Base 1’s destructor
    Base 2’s destructor
    Derived’s Destructor
  2. Derived’s Destructor
    Base 2’s destructor
    Base 1’s destructor
  3. Derived’s Destructor
  4. Compiler Dependent
Answer

Derived’s Destructor
Base 2’s destructor
Base 1’s destructor

NIELIT 2017 July Scientist B (IT)

Q. What is the Basis of Encapsulation’?

  1. object
  2. class
  3. method
  4. all of the mentioned
Answer

all of the mentioned
NIELIT 2017 OCT Scientific Assistant A (IT)

Q. Which of the following Interface is not supported by JDBC for connecting to Database in Java Programming language?

  1. Statement Interface
  2. Prepared Statement Interface
  3. Callable Statement Interface
  4. Database Interface
Answer

Database Interface
NIELIT Scientific Assistant A 2020 November

Q. Memory-mapped displays

  1. are utilized for high-resolution graphics such as maps
  2. uses ordinary memory to store the display data in character form
  3. stores the display data as individual bits
  4. are associated with electromechanical teleprinters
Answer

uses ordinary memory to store the display data in character form
NIELIT 2016 MAR Scientist C

Q. Consider a program with following data:
Unique operator = 10, unique operands = 15
Total operator =30, Total operands = 40
What is the estimated length of program?

  1. 132
  2. 92
  3. 32
  4. 82
Answer

82
NIELIT 2021 Dec Scientist B

Q. In C++, dynamic memory allocation is accomplished with which of the following operator:

  1. this
  2. new
  3. delete
  4. malloc()
Answer

new
NIELIT 2021 Dec Scientist B

Q. If the objects focus on the problem domain, then we are concerned with

  1. Object Oriented Analysis
  2. Object Oriented Design
  3. Object Oriented Analysis and Design
  4. None of the above
Answer

Object Oriented Analysis
NIELIT 2017 OCT Scientific Assistant A (IT)

Q. In Java, the Dynamic Array are known as :

  1. Vectors
  2. Cycle
  3. Remote
  4. Kubernetes
Answer

Vectors
NIELIT Scientific Assistant A 2020 November

Q. Which of the following construct is not supported by Java Server Pages?

  1. JSP Directives
  2. JSP Scriptlets
  3. JSP Actions
  4. JSP Reaction
Answer

JSP Reaction
NIELIT Scientific Assistant A 2020 November

Q. Which of the following is/are true about packages in Java?
1. Every class is part of some package.
2. All classes in a file are part of the same package.
3. If no package is specified, the classes in the file go into a special unnamed package.
4. If no package is specified, a new package is created with folder name of class and the class is put in this package.

  1. Only 1,2 and 3
  2. Only 1,2 and 4
  3. Only 4
  4. Only 1 and 3
Answer

Only 1,2 and 3
NIELIT 2017 July Scientist B (IT)

Q. Which indicates use of virtual functions

  1. Overloading
  2. Overriding
  3. Static binding
  4. Dynamic binding
Answer

Dynamic binding
NIELIT 2021 Dec Scientist B

Q. In dynamic programming approach the optimum solution is calculated in the following way:

  1. Divide and conquer
  2. Top up fashion
  3. Bottom-up approach
  4. Mixed approach
Answer

Bottom-up approach
NIELIT 2021 Dec Scientist B

Q. Build & Fix Model is suitable for programming exercises of how many LOC(Line of Code)?

  1. 100-200
  2. 200-400
  3. 400-1000
  4. above 1000
Answer

100-200
NIELIT 2021 Dec Scientist B

Q. Which of the following is false about abstract classes in Java?

  1. If we derive an abstract class and do not implement all the abstract methods, then the derived class should
    also be marked as abstract using ‘abstract’ keyword.
  2. Abstract classes can have constructors.
  3. A class can be made abstract without any abstract method.
  4. A class can inherit from multiple abstract classes.
Answer

A class can inherit from multiple abstract classes.
NIELIT 2017 July Scientist B (IT)

Q. During exception handling, which of the following statements hold true?

  1. Single try can have multiple associated catch with it
  2. A single Catch can have multiple try associated with it
  3. Finally block execute only when the class is inherited
  4. For a given exception, multiple catch can execute
Answer

Single try can have multiple associated catch with it
NIELIT Scientific Assistant A 2020 November

Q. The shell

  1. accepts command from the user
  2. maintains directories of files
  3. translates the keyboard’s character codes
  4. none of these
Answer

accepts command from the user
NIELIT 2016 MAR Scientist B

Q. In the given program:

class Dialog1 {
  public static void main(String args[]) {
    Frame f1 = new Frame("INDIA");
    f1.setSize(300, 300);
    f1.setVisible(true);
    FileDialog d = new FileDialog(f1, "MyDialog");
    1. setVisible(true);
    String fname = 1. getDirectory() + 1. getFile();
    System.out.println("The Selection is" + fname);
  }
}

To make the Frame visible, which of the following statements are true?

  1. f1.setClear(true);
  2. f1.setVisible(true);
  3. f1.setlook(true);
  4. f1.setclean(true);
Answer

f1.setVisible(true);
NIELIT Scientific Assistant A 2020 November

Q. In Java, to ensure the persistence property, the class must implement:

  1. Serializable Interface
  2. Utilization Interface
  3. Threadable Interface
  4. Recognizable Interface
Answer

Serializable Interface
NIELIT Scientific Assistant A 2020 November

Q. Which of the following are two main types of overloading in Java?

  1. Overloading and linking
  2. Overriding and linking
  3. Reusability and data-hiding
  4. Overloading and Overriding
Answer

Overloading and Overriding
NIELIT Scientific Assistant A 2020 November

Scroll to Top