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
Answer: D
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
Answer: C
3. What
is the output of the following C program?
# include <stdio.h>
main ( )
{
int a, b=0;
static int c [10]={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
Answer: A
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
Answer: A
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.
Answer: C
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
Answer: A
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.
Answer: B
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
Answer: A
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
Answer: B
10. What
is the output of following statement?
for(i=1; i<4; i++)
printf(“%d”,(i%2) ? i : 2*i);
(A) 1 4 3 (B)
1 2 3
(C) 2 4 6 (D)
2 2 6
Answer: A
Explanation:
for i=1, (i%2) is true so the statement will
print 1; for for i=2, (i%2) is false so the statement will print 2*i=2*2=4; for
for i=3, (i%2) is again true so the statement will print 3; for i=4, the
statement is out from the loop.
0 Comments