This section contains more frequently asked Programming In C++ Objective Questions Answers in the various University Level and Competitive Examinations.

PRACTICE IT NOW TO SHARPEN YOUR CONCEPT AND KNOWLEDGE

view hide answers

1. What is the error in the following code? class t { virtual void print(); }

  • No error.
  • Function print() should be declared as static.
  • Function print() should be defined.
  • Class t should contain data members.

2. What will be the output of following program? #include void main() { float x; x=(float)9/2; cout x; }

  •  4.5
  •  4.0
  • 4
  • 5

3. A white space is :

  • blank space
  • new line
  • tab
  • all of the above

4. The following can be declared as friend in a class

  • an object
  • a class
  • a public data member
  • a private data member

5. What would be the output of the following? #include void main() { char *ptr=“abcd” char ch; ch = ++*ptr++; cout ch; }

  • a
  • b
  • c
  • d

6. A copy constructor takes

  • no argument
  • one argument
  •  two arguments
  • arbitrary no. of arguments

7. Overloading a postfix increment operator by means of a member function takes

  • no argument
  • one argument
  • two arguments
  • three arguments
  •  this.x
  • *this.x
  • *(this.x)
  • (*this).x

9. If we store the address of a derived class object into a variable whose type is a pointer to the base class, then the object, when accessed using this pointer.

  • continues to act like a derived class object.
  • Continues to act like a derived class object if virtual functions are called.
  • Acts like a base class object.
  • Acts like a base class, if virtual functions are called.

10. Which of the following declarations are illegal?

  •  void *ptr;
  • char *str = “hello”;
  • char str = “hello”;
  • const *int p1;
Share with : Share on Linkedin Share on Twitter Share on WhatsApp Share on Facebook