 Sample Questions, Previous Year Solved Papers, Study Materials For Competitive Examinations Like UGC NET, SET And GATE Computer Science.

## Tuesday, 18 October 2016

1.       A ................. converts from an object of the type of the constructor parameter to an object of the class.
(A) conversion function         (B) member function
(C) class conversion               (D) conversion constructors
2.       ................ function converts an object of the class in which you define the function to an object of different data type.
(A) conversion function         (B) member function
(C) class conversion               (D) conversion constructors
3.       What is the output of the following C program?
# include <stdio.h>
main ( )
{
int a, b=0;
static int c ={1,2,3,4,5,6,7,8,9,0};
for (a=0; a<10;+ + a)
if ((c[a]%2)= = 0) b+ = c [a];
printf (“%d”, b);
}
(A) 20     (B) 25
(C) 45     (D) 90
Explanation:
printf statement will print b which is sum of the those values from array c which get divided by 2, that is 2+4+6+8=20.
4.       If a, b and c are integer variables with the values a=8, b=3 and c=-5. Then what is the value of the arithmetic expression:
2 * b + 3 * (a-c)
(A) 45                 (B) 6
(C) -16               (D) -1
Explanation:
the value of the arithmetic expression is 45 as 2*3+3*(8- -5)=6+3*13=6+39=45
5.       A global variable is a variable
(A) declared in the main ( ) function.
(B) declared in any function other than the main ( ) function.
(C) declared outside the body of every function.
(D) declared any where in the C program.
Explanation:
A global variable is declared outside the body of every function.

6.       When a function returns a reference it ...................
(A) returns an implicit pointer to its return value
(B) displays that pointer
(C) returns the value referring to it
(D) does not return anything
7.       Which of the following is not true with the reference variable?
(A) References eliminate the overhead associated with passing large data structures as parameters.
(B) It cannot be used to reduce complex notation.
(C) References eliminate pointer dereference notation.
(D) It is a copy alias for another variable.
8.       What is the following function computing? Assume a and b are positive integers.
int fn( int a, int b) {
if (b == 0)
return b;
else
return (a * fn(a, b - 1));
}
(A) Output will be 0 always    (B) Output will always be b
(C) Computing ab                    (D) Computing a + b
Explanation:
The output is always be 0 because b is decremented in recursive function fn each time by 1 till the terminating condition b==0 where it will return 0.
9.       Which of the following is not a looping statement in C?
(A) while                        (B) until
(C) do                 (D) for