Online C++ Programming Test - C++ Programming Test 4



Loading...  Loading Test...

Instruction:

  • This is a FREE online test. DO NOT pay money to anyone to attend this test.
  • Total number of questions : 20.
  • Time alloted : 30 minutes.
  • Each question carry 1 mark, no negative marks.
  • DO NOT refresh the page.
  • All the best :-).


1.

Which of the following type of class allows only one object of it to be created?

A.
Virtual class
B.
Abstract class
C.
Singleton class
D.
Friend class

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : OOPS Concepts

Discuss about this problem : Discuss in Forum


2.

How many instances of an abstract class can be created?

A.
1
B.
5
C.
13
D.
0

Your Answer: Option (Not Answered)

Correct Answer: Option D

Learn more problems on : OOPS Concepts

Discuss about this problem : Discuss in Forum


3.

Why reference is not same as a pointer?

A.
A reference can never be null.
B.
A reference once established cannot be changed.
C.
Reference doesn't need an explicit dereferencing mechanism.
D.
All of the above.

Your Answer: Option (Not Answered)

Correct Answer: Option D

Learn more problems on : OOPS Concepts

Discuss about this problem : Discuss in Forum


4.

How "Late binding" is implemented in C++?

A.
Using C++ tables
B.
Using Virtual tables
C.
Using Indexed virtual tables
D.
Using polymorphic tables

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : OOPS Concepts

Discuss about this problem : Discuss in Forum


5.

Which of the following header file includes definition of cin and cout?

A.
istream.h
B.
ostream.h
C.
iomanip.h
D.
iostream.h

Your Answer: Option (Not Answered)

Correct Answer: Option D

Learn more problems on : OOPS Concepts

Discuss about this problem : Discuss in Forum


6.

Which of the following provides a reuse mechanism?

A.
Abstraction
B.
Inheritance
C.
Dynamic binding
D.
Encapsulation

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : OOPS Concepts

Discuss about this problem : Discuss in Forum


7.

Which of the following statement will be correct if the function has three arguments passed to it?

A.
The trailing argument will be the default argument.
B.
The first argument will be the default argument.
C.
The middle argument will be the default argument.
D.
All the argument will be the default argument.

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Functions

Discuss about this problem : Discuss in Forum


8.

Which of the following statement is correct?

A.
Overloaded functions can accept same number of arguments.
B.
Overloaded functions always return value of same data type.
C.
Overloaded functions can accept only same number and same type of arguments.
D.
Overloaded functions can accept only different number and different type of arguments.

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Functions

Discuss about this problem : Discuss in Forum


9.

Which of the following function / types of function cannot have default parameters?

A.
Member function of class
B.
main()
C.
Member function of structure
D.
Both B and C

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Functions

Discuss about this problem : Discuss in Forum


10.

What will be the output of the following program?

#include<iostream.h> 
struct IndiaBix
{
    int arr[5]; 
    public:
    void BixFunction(void);
    void Display(void);
};
void IndiaBix::Display(void)
{
    for(int i = 0; i < 5; i++) 
        cout<< arr[i] << " " ;
}
void IndiaBix::BixFunction(void)
{
    static int i = 0, j = 4; 
    int tmp = arr[i]; 
    arr[i]  = arr[j]; 
    arr[j]  = tmp   ; 
    i++;
    j--;
    if(j != i) BixFunction();
}
int main()
{
    IndiaBix objBix = {{ 5, 6, 3, 9, 0 }};
    objBix.BixFunction();
    objBix.Display();
    return 0; 
}

A.
0 9 3 6 5
B.
9 3 6 5 0
C.
5 6 3 9 0
D.
5 9 3 6 0

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Functions

Discuss about this problem : Discuss in Forum


11.

What is correct about the following program?

#include<iostream.h> 
class Base
{
    int x, y, z; 
    public: 
    Base()
    {
        x = y = z = 0;
    }
    Base(int xx, int yy = 'A', int zz = 'B')
    {
        x = xx;
        y = x + yy;
        z = x + y;
    }
    void Display(void)
    {
        cout<< x << " " << y << " " << z << endl;
    }
};
class Derived : public Base
{
    int x, y; 
    public:
    Derived(int xx = 65, int yy = 66) : Base(xx, yy)
    {
        y = xx; 
        x = yy;
    }
    void Display(void)
    {
        cout<< x << " " << y << " ";
        Display(); 
    }
};
int main()
{
    Derived objD;
    objD.Display();
    return 0; 
}

A.
The program will report compilation error.
B.
The program will run successfully giving the output 66 65.
C.
The program will run successfully giving the output 65 66.
D.
The program will run successfully giving the output 66 65 65 131 196.
E.
The program will produce the output 66 65 infinite number of times (or till stack memory overflow).

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : Functions

Discuss about this problem : Discuss in Forum


12.

Which of the following statement is correct?

A.
A reference is declared using * operator.
B.
Once a reference variable has been defined to refer to a particular variable it can refer to any other variable.
C.
A reference must always be initialized within classes.
D.
A variable can have multiple references.

Your Answer: Option (Not Answered)

Correct Answer: Option D

Learn more problems on : References

Discuss about this problem : Discuss in Forum


13.

Which of the following statement is correct about the program given below?

#include<iostream.h> 
class IndiaBix
{
    int x, y; 
    public:
    void SetValue(int &a, int &b)
    {
        a = 100;
        x = a;
        y = b;
        Display();
    }
    void Display()
    {
        cout<< x << " " << y; 
    }
};
int main()
{
    int x = 10;
    IndiaBix objBix;
    objBix.SetValue(x, x);
    return 0;
}

A.
The program will print the output 100 10.
B.
The program will print the output 100 100.
C.
The program will print the output 100 garbage.
D.
The program will print two garbage values.
E.
It will result in a compile time error.

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : References

Discuss about this problem : Discuss in Forum


14.

Which of the following two entities (reading from Left to Right) can be connected by the dot operator?

A.
A class member and a class object.
B.
A class object and a class.
C.
A class and a member of that class.
D.
A class object and a member of that class.

Your Answer: Option (Not Answered)

Correct Answer: Option D

Learn more problems on : Objects and Classes

Discuss about this problem : Discuss in Forum


15.

Which of the following also known as an instance of a class?

A.
Friend Functions
B.
Object
C.
Member Functions
D.
Member Variables

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Objects and Classes

Discuss about this problem : Discuss in Forum


16.

Constructor is executed when _____.

A.
an object is created
B.
an object is used
C.
a class is declared
D.
an object goes out of scope.

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Objects and Classes

Discuss about this problem : Discuss in Forum


17.

Which of the following gets called when an object goes out of scope?

A.
constructor
B.
destructor
C.
main
D.
virtual function

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Constructors and Destructors

Discuss about this problem : Discuss in Forum


18.

It is a __________ error to pass arguments to a destructor.

A.
logical
B.
virtual
C.
syntax
D.
linker

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : Constructors and Destructors

Discuss about this problem : Discuss in Forum


19.

Which of the following gets called when an object is being created?

A.
constructor
B.
virtual function
C.
destructor
D.
main

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Constructors and Destructors

Discuss about this problem : Discuss in Forum


20.

Which of the following statement is correct about the program given below?

#include<iostream.h> 
class IndiaBix
{
    int x; 
    public:
    IndiaBix(short ss)
    {
        cout<< "Short" << endl;
    }
    IndiaBix(int xx)
    {
        cout<< "Int" << endl;
    }
    IndiaBix(char ch)
    {
        cout<< "Char" << endl;
    }
    ~IndiaBix() 
    {
        cout<< "Final";
    }
};
int main()
{
    IndiaBix *ptr = new IndiaBix('B');
    return 0; 
}

A.
The program will print the output Short .
B.
The program will print the output Int .
C.
The program will print the output Char .
D.
The program will print the output Final .
E.
None of the above

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : Constructors and Destructors

Discuss about this problem : Discuss in Forum


Submit your test now to view the Results and Statistics with answer explanation.