Online C++ Programming Test - C++ Programming Test - Random

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.
Which of the following operators cannot be overloaded?
[]
->
?:
*
Your Answer: Option
(Not Answered)
Correct Answer: Option

2.
Which of the following statement is correct?
A constructor is called at the time of declaration of an object.
A constructor is called at the time of use of an object.
A constructor is called at the time of declaration of a class.
A constructor is called at the time of use of a class.
Your Answer: Option
(Not Answered)
Correct Answer: Option

3.
Which of the following is not the member of class?
Static function
Friend function
Const function
Virtual function
Your Answer: Option
(Not Answered)
Correct Answer: Option

4.
Which of the following is an abstract data type?
int
double
string
Class
Your Answer: Option
(Not Answered)
Correct Answer: Option

5.
Which of the following statements regarding inline functions is correct?
It speeds up execution.
It slows down execution.
It increases the code size.
Both A and C.
Your Answer: Option
(Not Answered)
Correct Answer: Option

6.
Which of the following statement is incorrect?
The default value for an argument can be a global constant.
The default arguments are given in the function prototype.
Compiler uses the prototype information to build a call, not the function definition.
The default arguments are given in the function prototype and should be repeated in the function definition.
Your Answer: Option
(Not Answered)
Correct Answer: Option

7.
What will be the output of the following program?
#include<iostream.h> 
class Bix
{
    int x, y; 
    public:
    void show(void);
    void main(void);
};
void Bix::show(void)
{ 
    Bix b;
    b.x = 2;
    b.y = 4;
    cout<< x << " " << y;
}
void Bix::main(void)
{
    Bix b;
    b.x = 6; 
    b.y = 8;
    b.show();
}
int main(int argc, char *argv[])
{
    Bix run;
    run.main();
    return 0; 
}
2 4
6 8
The program will report error on Compilation.
The program will report error on Linking.
The program will report error on Run-time.
Your Answer: Option
(Not Answered)
Correct Answer: Option

8.
What will be the output of the following program?
#include<iostream.h> 
struct MyData
{
    public:
    int Addition(int a, int b = 10)
    {
        return (a *= b + 2);
    }
    float Addition(int a, float b);
};
int main()
{
    MyData data;
    cout<<data.Addition(1)<<" ";
    cout<<data.Addition(3, 4);
    return 0; 
}
12 12
12 18
3 14
18 12
Compilation fails.
Your Answer: Option
(Not Answered)
Correct Answer: Option

9.
Which of the following statement is correct about the program given below?
#include<iostream.h>
const double BixConstant(const int, const int = 0);
int main()
{
    const int c = 2 ;
    cout<< BixConstant(c, 10)<< " "; 
    cout<< BixConstant(c, 20)<< endl; 
    return 0;
}
const double BixConstant(const int x, const int y)
{
    return( (y + (y * x) * x % y) * 0.2);
}
The program will print the output 2 4.
The program will print the output 20 40.
The program will print the output 10 20.
The program will print the output 20 4.50.
The program will report compile time error.
Your Answer: Option
(Not Answered)
Correct Answer: Option

10.
Which of the following statement is correct about the program given below?
#include<iostream.h> 
enum bix
{
    a=1, b, c
};
int main()
{
    int x = c;
    int &y = x;
    int &z = x;
    y = b;
    cout<< z--;
    return 0; 
}
It will result in a compile time error.
The program will print the output 1.
The program will print the output 2.
The program will print the output 3.
Your Answer: Option
(Not Answered)
Correct Answer: Option

11.
Which of the following statement is correct about the program given below?
#include<iostream.h> 
class Bix
{
    int x, y; 
    public:
    Bix(int x, int y)
    {
        this->x = x;
        this->y = y;
    }
    void Display()
    {
        cout<< x << " " << y;
    }
};
int main()
{
    int x = 50;
    int &y = x ;
    Bix b(y, x);
    return 0; 
}
The program will print the output 50 50.
The program will print the two garbage values.
It will result in a compile time error.
The program will print nothing.
Your Answer: Option
(Not Answered)
Correct Answer: Option

12.
Which of the following statement is correct about the program given below?
#include<iostream.h> 
enum xyz
{
    a, b, c
};
int main() 
{
    int x = a, y = b, z = c;
    int &p = x, &q = y, &r = z;
    p = ++x;
    q = ++y;
    r = ++c;
    cout<< p << q << r;
    return 0;
}
The program will print the output 1 2 3.
The program will print the output 2 3 4.
The program will print the output 0 1 2.
It will result in a compile time error.
Your Answer: Option
(Not Answered)
Correct Answer: Option

13.
Which of the following statement is correct regarding destructor of base class?
Destructor of base class should always be static.
Destructor of base class should always be virtual.
Destructor of base class should not be virtual.
Destructor of base class should always be private.
Your Answer: Option
(Not Answered)
Correct Answer: Option

14.
What will be the output of the following program?
#include<iostream.h>
#include<string.h> 
class IndiaBix
{
    char str[50]; 
    char tmp[50]; 
    public:
    IndiaBix(char *s)
    {
        strcpy(str, s);
    }
    int BixFunction()
    {
        int i = 0, j = 0; 
        while(*(str + i))
        {
            if(*(str + i++) == ' ')
                *(tmp + j++) = *(str + i);
        }
        *(tmp + j) = 0; 
        return strlen(tmp); 
    }
};
int main()
{
    char txt[] = "Welcome to IndiaBix.com!";
    IndiaBix objBix(txt); 
    cout<< objBix.BixFunction();
    return 0;
}
1
2
24
25
Your Answer: Option
(Not Answered)
Correct Answer: Option

15.
Which of the following statement is correct about the program given below?
#include<iostream.h> 
class BixBase
{
    int x, y; 
    public:
    BixBase(int xx = 10, int yy = 10)
    {
        x = xx;
        y = yy;
    }
    void Show()
    {
        cout<< x * y << endl;
    }
};
class BixDerived : public BixBase
{
    private:
        BixBase objBase; 
    public:
    BixDerived(int xx, int yy) : BixBase(xx, yy)
    {
        objBase.Show();
    }
};
int main()
{
    BixDerived objDev(10, 20);
    return 0; 
}
The program will print the output 100.
The program will print the output 200.
The program will print the output Garbage-value.
The program will report compile time error.
Your Answer: Option
(Not Answered)
Correct Answer: Option

16.
A constructor that accepts __________ parameters is called the default constructor.
one
two
no
three
Your Answer: Option
(Not Answered)
Correct Answer: Option

17.
Which of the following statements are correct?
Constructor is always called explicitly.
Constructor is called either implicitly or explicitly, whereas destructor is always called implicitly.
Destructor is always called explicitly.
Constructor and destructor functions are not called at all as they are always inline.
Your Answer: Option
(Not Answered)
Correct Answer: Option

18.
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

19.
Which of the following statement is correct?
A destructor has the same name as the class in which it is present.
A destructor has a different name than the class in which it is present.
A destructor always returns an integer.
A destructor can be overloaded.
Your Answer: Option
(Not Answered)
Correct Answer: Option

20.
What is the technical word for the function ~IndiaBix() defined in the following program?
#include<iostream.h> 
class IndiaBix
{
    int x, y; 
    public:
    IndiaBix(int xx = 10, int yy = 20 )
    {
        x = xx; 
        y = yy;
    }
    void Display()
    {
        cout<< x << " " << y << endl;
    } 
    ~IndiaBix()
    { } 
};
int main()
{
    IndiaBix objBix; 
    objBix.Display(); 
    return 0;
}
Constructor
Destructor
Default Destructor
Function Template
Your Answer: Option
(Not Answered)
Correct Answer: Option

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