Placement papers on C++ - Set 5

Placement papers on C++ - Set 5


1. Declaration of a pointer reserves memory space

for the object.
for the pointer.
both for the object and the pointer
none of these.
View Answer / Hide Answer

ANSWER: for the pointer.




2. Consider the following statements

char *ptr;
ptr = hello;
cout << *ptr;

What will be printed?

first letter
entire string
it is a syntax error
last letter
View Answer / Hide Answer

ANSWER: first letter




3. In which case is it mandatory to provide a destructor in a class?

Almost in every class
Class for which two or more than two objects will be created
Class for which copy constructor is defined
Class whose objects will be created dynamically
View Answer / Hide Answer

ANSWER: Class whose objects will be created dynamically




4. The members of a class, by default, are

public
protected
private
mandatory to specify
View Answer / Hide Answer

ANSWER: private




5. What is the output of the following code

char symbol[3]={a,b,c};

for (int index=0; index < 3; index++)

cout << symbol [index];

a b c
abc
abc
abc
View Answer / Hide Answer

ANSWER: abc




6. The process of building new classes from existing one is called ______

Polymorphism
Structure
Inheritance
Cascading
View Answer / Hide Answer

ANSWER: Inheritance




7. To perform stream I/O with disk files in C++, you should

open and close files as in procedural languages.
use classes derived from ios.
use C language library functions to read and write data.
include the IOSTREAM.H header file.
View Answer / Hide Answer

ANSWER: use classes derived from ios.




8. RunTime Polymorphism is achieved by ______

friend function
virtual function
operator overloading
function overloading
View Answer / Hide Answer

ANSWER: virtual function




9. In C++, dynamic memory allocation is accomplished with the operator ____

new
this
malloc( )
delete
View Answer / Hide Answer

ANSWER: new




10. Overloading the function operator

requires a class with an overloaded operator.
requires a class with an overloaded [ ] operator.
allows you to create objects that act syntactically like functions.
usually make use of a constructor that takes arguments.
View Answer / Hide Answer

ANSWER: requires a class with an overloaded operator.


Post your comment