C & C++ Programming Multiple Choice Questions - Set 41

1.       Which of the following is true for the statement:
NurseryLand.Nursery.Students = 10;
(A) The structure Students is nested within the structure Nursery.
(B) The structure NurseryLand is nested within the structure Nursery.
(C) The structure Nursery is nested within the structure NurseryLand.
(D) The structure Nursery is nested within the structure Students.
Answer: C
Explanation:
The structure Nursery is nested within the structure NurseryLand.
2.       Unsigned integer occupies ..................
(A) Two bytes
(B) Four bytes
(C) One byte
(D) Eight bytes
Answer: B
3.       The operators << and >> are
(A) assignment operator
(B) relational operator
(C) logical operator
(D) bitwise shift operator
Answer: D
4.       Which of the following numerical value is invalid constant
(A) .75
(B) 9.3e2
(C) 27,512
(D) 123456
Answer: C
5.       A C program contains the following declaration int i=8, j=5 what would be the value of
following expression ?
abs(i-2*j)
(A) 2
(B) 4
(C) 6
(D) 8
Answer: A

6.       What will be the output of the following program
main( )
{
int k, num=30;
k=(num>5 ? (num<= 10 ? 100:200):500);
printf(“\n%d”, num);
}
(A) 100
(B) 5
(C) 30
(D) 500
Answer: C
7.       What is the output of the following code
int n = 0, m=1;
do
{
printf(“%d”, m);
m++;
}
while(m<=n);
(A) 0
(B) 2
(C) 1
(D) 4
Answer: C
8.       In which case is it mandatory to provide a destructor in a class?
(A) Almost in every class
(B) Class for which two or more than two objects will be created
(C) Class for which copy constructor is defined
(D) Class whose objects will be created dynamically
Answer: D
9.       The members of a class, by default, are
(A) public
(B) protected
(C) private
(D) mandatory to specify
Answer: C
10.    Given a class named Book, which of the following is not a valid constructor?
(A) Book ( ) { }
(B) Book ( Book b) { }
(C) Book ( Book &b) { }
(D) Book (char* author, char* title) { }
Answer: B


Post a Comment

0 Comments