Computer Science Study Materials for Competitive Exams

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

Wednesday, 26 July 2017

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

1.       The new operator
(A) returns a pointer to the variable
(B) creates a variable called new
(C) obtains memory for a new variable
(D) tells how much memory is available
Answer: C
2.       Consider the following statements:
int x = 22,y=15;
x = (x>y) ? (x+y) : (x-y);
What will be the value of x after executing these statements?
(A) 22
(B) 37
(C) 7
(D) Error. Cannot be executed
Answer: B
3.       An exception is caused by
(A) a hardware problem
(B) a problem in the operating system
(C) a syntax error
(D) a run-time error
Answer: D
4.       A virtual class is the same as
(A) an abstract class
(B) a class with a virtual function
(C) a base class
(D) none of the above.
Answer: D
5.       Identify the operator that is NOT used with pointers
(A) ->
(B) &
(C) *
(D) >>
Answer: D

6.       Consider the following statements
char *ptr;
ptr = “hello”;
cout << *ptr;
What will be printed?
(A) first letter
(B) entire string
(C) it is a syntax error
(D) last letter
Answer: A
7.       In C a variable cannot contain
(A) Blank spaces
(B) Hyphen
(C) Decimal point
(D) All the above
Answer: D
8.       Which of the following is FALSE in C ?
(A) Keywords can be used as variable names
(B) Variable names can contain a digit
(C) Variable names do not contain a blank space
(D) Capital letters can be used in variable names
Answer: A
9.       In C, Arithmetic instruction cannot contain ..............
(A) variables
(B) constants
(C) variable names on right side of =
(D) constants on left side of =
Answer: D
10.    When a copy of an entire object is passed to a function, then it is referred to as
(A) Pass-by-reference
(B) Pass-by-pointer
(C) Pass-by-value
(D) None of the above
Answer: C

No comments:

Post a Comment