Escolar Documentos
Profissional Documentos
Cultura Documentos
6. Which header file supports the functions - 13. A member function can always access
malloc() and calloc()? the data
A - stdlib.h B - memory.h A. In the object of which it is a member
C - math.h D - stdio.h B. In the class of which it is a member
C. In any object of the class of which it is a
7. Which of the following variable cannot be member
used by switch-case statement? D. In the public part of its class
D. parameterized
14. The dot operator/ class member access
operator connects the following two entities 21. How many private, public or protected
reading from left to right sections can be there in a class?
A. A class member and a class object A. One
B. A class object and class member B. Two
C. A class and class object C. Three
D. A class and member of that class D. Multiple
15. The scope resolution operator connects 22. The Members of a class can be
the following two entities reading from left to A. Data
right B. Member Functions
A. A class member and a class object C. Type Definitions
B. A class object and class member D. All of the above
C. A class and class object
D. A class and member of that class 23. With every use of a memory allocation
function, what function should be used to release
16. A class ABC has objects obj1, obj2, allocated memory which is no longer needed?
obj3. for the statement obj3=obj2-obj1 to work A. unalloc(), B. dropmem()
the overloaded operator ?-? must C. dealloc() D. free()
A. take two arguments
B. Return a value 24. int testarray[2][2][2] = {11, 22, 33, 44, 55,
C. Create a named temporary object 66, 77, 88}; What value does testarray[1][1][0]
D. Use the object of which it is a member in the sample code above contain?
as an operand A. 55 B. 77 C. 88
D. 11
17. To convert from a user defined class to a
basic type , which of these is necessary 25. int a=10,b; b=a++ + ++a;
A. Built in conversion printf("%d,%d,%d,%d",b,a++,a,++a); what will
B. A one argument constructor be the output when following code is executed
C. An overloaded = operator A. 12,10,11,13, B. 22,10,11,13
D. A conversion function that?s the C. 22,11,11,11 D.
member of the class 22,13,13,13
18. Member functions defined inside the 26. When reallocating memory if any other
class definition ,by default are called pointers point into same piece of memory do
A. Member Function these pointers-
B. Inline Function A. need to be readjusted B.
C. Constructor they get readjusted automatically
D. Parameterized function C. C does it on behalf of user D.
none of above
19. When arithmetic assignment operator is
overloaded , the result 27. What is the output of the following
A. Goes in the object to right of the program? void main() { int *ptr =55; clrscr();
operator printf("%d", ++(ptr)); }
B. Goes in the object to the left of the A. 54 B. 55 C. 56
operator D. some address
C. Goes in the object of which the operator
is a member 28. main() { int i, j, *p; i = 25; j = 100; p =
D. Must be returned &i; printf("%f", i/(*p) ); }
A. Compile erro
20. Which of these is not a valid constructor B. 1.00000
type- C. Runtime error.
A. inline D. 0.00000
B. copy
C. default
29. main() { int i, j; scanf("%d have to worry about respecting the class
%d"+scanf("%d %d", &i, &j)); printf("%d %d", interface
i, j); } B. They allow us to break the
A. Compile error encapsulation of other user-defined classes
B. 0, 0 whenever we want, thereby enabling us to
C. Runtime error. improve efficiency
D. the first two values entered by the user. C. They allow us to break encapsulation in
a controlled manner, which ensures that
30. In the following code, in which order efficiency does not compromise maintainability
the functions would be called? x = D. They prevent non-overloaded functions
f1(23,14)*f2(12/4)+f3(); from getting lonely
A. f1, f2, f3
B. f3, f2, f1 35. Apart from operator=, the operators
C. The order may vary from compiler to most commonly overloaded are operator<< and
compiler operator>>. Why?
D. None of the above A. Because left- and right-shifting is a very
common task in programs.
31. If a binary operator is overloaded as a B. Because they can be member functions
member function, how many parameters will the or global functions.
member function require? C. Because they make it easy to do I/O on
A. None. Both operands are passed via the user-defined classes.
object. D. Because in early versions of C++, they
B. One, to pass the second operand. The were the only operators which could be
first operand is the object itself. overloaded.
C. Two, to pass the first and second
operands. 36. A friend of a class is also automatically
D. Binary operators can't be overloaded at a friend of
all. A. its base class(es)
B. its derived class(es)
32. What constraints does the compiler put C. any other friends of the class
on a const member function? D. none of the above
A. It cannot change any mutable data
member of the object on which it is called 37. Which of these is not true about static
B. It cannot change any non-mutable data data member?
member of the object on which it is called A. Can be accessed only static members
C. It cannot call any other non-const B. Each object of the class will have its
member function of the object on which it is own copy of static data member
called C. Memory will be allocates only once
D. It cannot change any non-mutable data during the class declaration
member, nor call any other non-const member D. When any object modifies static data
function, of the object on which it is called member , the result will be visible to all
instances of the class
33. A "friend" function is one which:
A. Belongs to a particular class, but (in 38. Which of these is false about static
some ways) acts like is doesn't. member functions?
B. Doesn't belong to a particular class, but A. Static member functions cannot be
(in some ways) acts like it does. defined in the private section of a class
C. Belongs to a particular class, but can be B. Can access only static data members of
called without referring to an object of that class. the class
D. Is a private member of a class, which C. Static member functions can invoke
exists just to "help" the public member functions other static member functions
D. Static member functions defined in the
34. Friend functions are useful because: public section of a class declaration can not be
A. They allow us to break the accessed without specifying an object of the
encapsulation of any class whenever we want to, class
which makes coding much easier since we don't
39. Which is the parameter that is added to a) 1 b) Compile time error c) 2 d) Run
every non-static member function when it is time error
called?
A. Constructor 43. Which of the following is not a type of
B. 'this' pointer constructor?
C. Void * A. Copy constructor
D. reference B. Friend constructor
C. Default constructor
40. To convert from a basic type to a user D. Parameterized constructor
defined class , which of these is necessary
A. Built in conversion 44. Which of the following statements is
B. A one argument constructor correct?
C. An operator function A. Base class pointer cannot point to
D. A conversion function that?s the derived class.
member of the class B. Derived class pointer cannot point to
base class.
41.What is the output of this C code(when 1 is C. Pointer to derived class cannot be
entered)? created.
#include <stdio.h> D. Pointer to base class cannot be created.
void main()
{
double ch; 45. Which of the following is not the member of
printf("enter a value btw 1 to 2:"); class?
scanf("%lf", &ch); A. Static function
switch (ch) B. Friend function
{ C. Const function
case 1: D. Virtual function
printf("1");
break;
case 2: 46. Which of the following concepts means
printf("2"); determining at runtime what method to invoke?
break; A. Data hiding
} B. Dynamic Typing
} C. Dynamic binding
a) Compile time error b) 1 c) 2 D. Dynamic loading
d) Varies
42. What is the output of this C code(When 1 is 47.Which of the following concepts provides
entered)? facility of using object of one class inside
#include <stdio.h> another class?
void main() A. Encapsulation
{ B. Abstraction
char *ch; C. Composition
printf("enter a value btw 1 to 3:"); D. Inheritance
scanf("%s", ch);
switch (ch)
{ 48.Which of the following is the correct class of
case "1": the object cout?
printf("1"); A. iostream
break; B. istream
case "2": C. ostream
printf("2"); D. ifstream
break;
}
}
49.Which of the following is the correct way of fstream
declaring a function as constant? iostream
A. const int ShowData(void) { /* 56. ios::trunc is used for ?
statements */ } A. If the file is opened for output
B. int const ShowData(void) { /* operations and it already existed, no
statements */ } action is taken.
C. int ShowData(void) const { /* B. If the file is opened for output
statements */ } operations and it already existed, its
D. Both A and B previous content is deleted and replaced
by the new one.
50.Which of the following ways are legal to C. If the file is opened for output
access a class data member using this pointer? operations and it already existed, then a
A. this->x new copy is created.
B. this.x D. None of above
C. *this.x 57. Which is correct syntax ?
D. *this-x A. myfile:open ("example.bin", ios::out);
B. myfile.open ("example.bin", ios::out);
51.Which of the following operators cannot be C. myfile::open ("example.bin", ios::out);
overloaded? D. myfile.open ("example.bin", ios:out);
A. [] 59. Which among following is correct syntax of
B. -> closing a file in c++ ?
C. ?: A. myfile$close();
D. * B. myfile@close();
C. myfile:close();
51. The fields in a structure of a C program are D. myfile.close();
by default 60. Which is used to handle the exceptions in
A.protected c++?
B.public A. catch handler
C.private B. handler
D.none of the above C. exception handler
52. When a class serves as base class for many D. none of the mentioned
derived classes, the situation is called:
A. polymorphism 61 Which statement is used to catch all types of
B. hierarchical inheritance exceptions?
C. hybrid inheritance a) catch()
D. multipath inheritance b) catch(Test t)
E. none of these c) catch(…)
53. When two or more classes serve as base d) none of the mentioned
class for a derived class, the situation is known
as __________. 62. How to handle error in the destructor?
A. multiple inheritance a) throwing
B. polymorphism b) terminate
C. encapsulation c) both a & b
D. hierarchical inheritance d) none of the mentioned
E. none of these
63. When the angle of incidence is _______ the
54. Multiple inheritance leaves room for a critical angle, the light beam bends along the
derived class to have _______ members. interface.
A. dynamic
B. private A) less than
C. public B) equal to
D. ambiguous C) more than
E. none of these D) none of the above
55. Which stream class is to only write on files ?
ofstream
ifstream
64. Transmission media lie below the _______ C) diameter of cable
layer. D) outer conductor