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

Instruction:

  • This is a FREE online test. Beware of scammers who ask for money to attend this test.
  • Total number of questions: 20.
  • Time allotted: 30 minutes.
  • Each question carries 1 mark; there are no negative marks.
  • DO NOT refresh the page.
  • All the best!

Marks : 2/20


Total number of questions
20
Number of answered questions
0
Number of unanswered questions
20
Test Review : View answers and explanation for this test.

1.
How many instances of an abstract class can be created?
1
5
13
0
Your Answer: Option
(Not Answered)
Correct Answer: Option

2.
Which of the following header file includes definition of cin and cout?
istream.h
ostream.h
iomanip.h
iostream.h
Your Answer: Option
(Not Answered)
Correct Answer: Option

3.
Which of the following provides a reuse mechanism?
Abstraction
Inheritance
Dynamic binding
Encapsulation
Your Answer: Option
(Not Answered)
Correct Answer: Option

4.
How "Late binding" is implemented in C++?
Using C++ tables
Using Virtual tables
Using Indexed virtual tables
Using polymorphic tables
Your Answer: Option
(Not Answered)
Correct Answer: Option

5.
Why reference is not same as a pointer?
A reference can never be null.
A reference once established cannot be changed.
Reference doesn't need an explicit dereferencing mechanism.
All of the above.
Your Answer: Option
(Not Answered)
Correct Answer: Option

6.
Which of the following type of class allows only one object of it to be created?
Virtual class
Abstract class
Singleton class
Friend class
Your Answer: Option
(Not Answered)
Correct Answer: Option

7.
Which of the following function / types of function cannot have default parameters?
Member function of class
main()
Member function of structure
Both B and C
Your Answer: Option
(Not Answered)
Correct Answer: Option

8.
Which of the following statement is correct?
Overloaded functions can accept same number of arguments.
Overloaded functions always return value of same data type.
Overloaded functions can accept only same number and same type of arguments.
Overloaded functions can accept only different number and different type of arguments.
Your Answer: Option
(Not Answered)
Correct Answer: Option

9.
Which of the following statement will be correct if the function has three arguments passed to it?
The trailing argument will be the default argument.
The first argument will be the default argument.
The middle argument will be the default argument.
All the argument will be the default argument.
Your Answer: Option
(Not Answered)
Correct Answer: Option

10.
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; 
}
The program will report compilation error.
The program will run successfully giving the output 66 65.
The program will run successfully giving the output 65 66.
The program will run successfully giving the output 66 65 65 131 196.
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

11.
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; 
}
0 9 3 6 5
9 3 6 5 0
5 6 3 9 0
5 9 3 6 0
Your Answer: Option
(Not Answered)
Correct Answer: Option

12.
Which of the following statement is correct?
A reference is declared using * operator.
Once a reference variable has been defined to refer to a particular variable it can refer to any other variable.
A reference must always be initialized within classes.
A variable can have multiple references.
Your Answer: Option
(Not Answered)
Correct Answer: Option

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;
}
The program will print the output 100 10.
The program will print the output 100 100.
The program will print the output 100 garbage.
The program will print two garbage values.
It will result in a compile time error.
Your Answer: Option
(Not Answered)
Correct Answer: Option

14.
Which of the following also known as an instance of a class?
Friend Functions
Object
Member Functions
Member Variables
Your Answer: Option
(Not Answered)
Correct Answer: Option

15.
Which of the following two entities (reading from Left to Right) can be connected by the dot operator?
A class member and a class object.
A class object and a class.
A class and a member of that class.
A class object and a member of that class.
Your Answer: Option
(Not Answered)
Correct Answer: Option

16.
Constructor is executed when _____.
an object is created
an object is used
a class is declared
an object goes out of scope.
Your Answer: Option
(Not Answered)
Correct Answer: Option

17.
Which of the following gets called when an object is being created?
constructor
virtual function
destructor
main
Your Answer: Option
(Not Answered)
Correct Answer: Option

18.
Which of the following gets called when an object goes out of scope?
constructor
destructor
main
virtual function
Your Answer: Option
(Not Answered)
Correct Answer: Option

19.
It is a __________ error to pass arguments to a destructor.
logical
virtual
syntax
linker
Your Answer: Option
(Not Answered)
Correct Answer: Option

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; 
}
The program will print the output Short .
The program will print the output Int .
The program will print the output Char .
The program will print the output Final .
None of the above
Your Answer: Option
(Not Answered)
Correct Answer: Option

*** END OF THE TEST ***
Time Left: 00:29:56
Post your test result / feedback here: