Online C++ Programming Test - C++ Programming Test 1

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 statement is correct?
C++ allows static type checking.
C++ allows dynamic type checking.
C++ allows static member function be of type const.
Both A and B.
Your Answer: Option
(Not Answered)
Correct Answer: Option

2.
Which of the following concepts means adding new components to a program as it runs?
Data hiding
Dynamic typing
Dynamic binding
Dynamic loading
Your Answer: Option
(Not Answered)
Correct Answer: Option

3.
Which of the following statement is correct?
The order of the default argument will be right to left.
The order of the default argument will be left to right.
The order of the default argument will be alternate.
The order of the default argument will be random.
Your Answer: Option
(Not Answered)
Correct Answer: Option

4.
Which of the following statement is correct?
Only one parameter of a function can be a default parameter.
Minimum one parameter of a function must be a default parameter.
All the parameters of a function can be default parameters.
No parameter of a function can be default.
Your Answer: Option
(Not Answered)
Correct Answer: Option

5.
What will be the output of the following program?
#include<iostream.h> 
class IndiabixSample
{
    public:
        int   a; 
        float b;
        void BixFunction(int a, float b, float c = 100.0f)
        {
            cout<< a % 20 + c * --b;
        } 
}; 
int main()
{   IndiabixSample objBix;
    objBix.BixFunction(20, 2.000000f, 5.0f);
    return 0; 
}
0
5
100
-5
None of these
Your Answer: Option
(Not Answered)
Correct Answer: Option

6.
What will be the output of the following program?
#include<iostream.h> 
class AreaFinder
{
    float l, b, h; 
    float result; 
    public:
    AreaFinder(float hh = 0, float ll = 0, float bb = 0) 
    {
        l = ll; 
        b = bb; 
        h = hh;
    }
    void Display(int ll)
    {
        if(l = 0)
            result = 3.14f * h * h; 
        else
            result = l * b; 
        cout<< result; 
    }
};
int main()
{
    AreaFinder objAF(10, 10, 20);
    objAF.Display(0); 
    return 0; 
}
0
314
314.0000
200.0000
Your Answer: Option
(Not Answered)
Correct Answer: Option

7.
Which of the following statement is correct about the program given below?
#include<iostream.h> 
class IndiaBix
{ 
    public:
    void Bix(int x = 15)
    {
        x = x/2; 
        if(x > 0)
            Bix(); 
        else
            cout<< x % 2; 
    } 
};
int main()
{
    IndiaBix objIB;
    objIB.Bix();
    return 0; 
}
The program will display 1.
The program will display 2.
The program will display 15.
The program will go into an infinite loop.
The program will report error on compilation.
Your Answer: Option
(Not Answered)
Correct Answer: Option

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

9.
What will be the output of the following program?
#include<iostream.h> 
class IndiaBix
{
    int K; 
    public:
    void BixFunction(float, int , char);
    void BixFunction(float, char, char);
    
};
int main()
{
    IndiaBix objIB;
    objIB.BixFunction(15.09, 'A', char('A' + 'A'));
    return 0;
}
void IndiaBix::BixFunction(float, char y, char z)
{
    K = int(z);
    K = int(y);
    K = y + z;
    cout<< "K = " << K << endl; 
}
The program will print the output M = 130.
The program will print the output M = 195.
The program will print the output M = -21.
The program will print the output M = -61.
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>
void Tester(float xx, float yy = 5.0);
class IndiaBix
{
    float x; 
    float y; 
    public:
    void Tester(float xx, float yy = 5.0)
    {
        x = xx;
        y = yy;
        cout<< ++x % --y; 
    }
};
int main()
{
    IndiaBix objBix;
    objBix.Tester(5.0, 5.0);
    return 0; 
}
The program will print the output 0.
The program will print the output 1.
The program will print the output 2.
The program will print the output garbage value.
The program will report compile time error.
Your Answer: Option
(Not Answered)
Correct Answer: Option

11.
Which of the following statements is correct?
  1. We can return a global variable by reference.
  2. We cannot return a local variable by reference.
Only 1 is correct.
Only 2 is correct.
Both 1 and 2 are correct.
Both 1 and 2 are incorrect.
Your Answer: Option
(Not Answered)
Correct Answer: Option

12.
Which of the following statement is correct about the program given below?
#include<iostream.h> 
class IndiaBix
{
    int x, y; 
    public:
    IndiaBix(int &xx, int &yy)
    {
        x = xx;
        y = yy;
        Display();
    }
    void Display()
    {
        cout<< x << " " << y;
    }
};
int main()
{
    int x1 = 10; 
    int &p = x1;
    int y1 = 20; 
    int &q = y1; 
    IndiaBix objBix(p, q); 
    return 0; 
}
It will result in a compile time error.
The program will print the output 10 20.
The program will print two garbage values.
The program will print the address of variable x1 and y1.
Your Answer: Option
(Not Answered)
Correct Answer: Option

13.
How many objects can be created from an abstract class?
Zero
One
Two
As many as we want
Your Answer: Option
(Not Answered)
Correct Answer: Option

14.
Which of the following statement is correct about the program given below?
#include<iostream.h> 
class IndiaBix
{
    static int x; 
    public:
    static void SetData(int xx)
    {
        x = xx; 
    }
    static void Display() 
    {
        cout<< x ;
    }
};
int IndiaBix::x = 0; 
int main()
{
    IndiaBix::SetData(44);
    IndiaBix::Display();
    return 0; 
}
The program will print the output 0.
The program will print the output 44.
The program will print the output Garbage.
The program will report compile time error.
Your Answer: Option
(Not Answered)
Correct Answer: Option

15.
What will be the output of the following program?
#include<iostream.h> 
class BixTeam
{
    int x, y; 
    public:
    BixTeam(int xx)
    {
        x = ++xx;
    }
    void Display()
    {
        cout<< --x << " ";
    }
};
int main()
{
    BixTeam objBT(45);
    objBT.Display();
    int *p = (int*)&objBT;
    *p = 23;
    objBT.Display();
    return 0; 
}
45 22
46 22
45 23
46 23
Your Answer: Option
(Not Answered)
Correct Answer: Option

16.
What will be the output of the following program?
#include<iostream.h> 
class Point
{
    int x, y; 
    public:
    Point(int xx = 10, int yy = 20)
    {
        x = xx;
        y = yy; 
    }
    Point operator + (Point objPoint)
    {
        Point objTmp;
        objTmp.x = objPoint.x + this->x; 
        objTmp.y = objPoint.y + this->y;
        return objTmp;
    }
    void Display(void)
    {
        cout<< x << " " << y;
    }
};
int main()
{
    Point objP1;
    Point objP2(1, 2);
    Point objP3 = objP1 + objP2;
    objP3.Display(); 
    return 0; 
}
1 2
10 20
11 22
Garbage Garbage
The program will report compile time error.
Your Answer: Option
(Not Answered)
Correct Answer: Option

17.
Which of the following statement is correct?
A constructor of a derived class can access any public and protected member of the base class.
Constructor cannot be inherited but the derived class can call them.
A constructor of a derived class cannot access any public and protected member of the base class.
Both A and B.
Your Answer: Option
(Not Answered)
Correct Answer: Option

18.
Which of the following implicitly creates a default constructor when the programmer does not explicitly define at least one constructor for a class?
Preprocessor
Linker
Loader
Compiler
Your Answer: Option
(Not Answered)
Correct Answer: Option

19.
For automatic objects, constructors and destructors are called each time the objects
enter and leave scope
inherit parent class
are constructed
are destroyed
Your Answer: Option
(Not Answered)
Correct Answer: Option

20.
Copy constructor must receive its arguments by __________ .
either pass-by-value or pass-by-reference
only pass-by-value
only pass-by-reference
only pass by address
Your Answer: Option
(Not Answered)
Correct Answer: Option

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