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



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 concepts means adding new components to a program as it runs?

A.
Data hiding
B.
Dynamic typing
C.
Dynamic binding
D.
Dynamic loading

Your Answer: Option (Not Answered)

Correct Answer: Option D

Learn more problems on : OOPS Concepts

Discuss about this problem : Discuss in Forum


2.

Which of the following statement is correct?

A.
C++ allows static type checking.
B.
C++ allows dynamic type checking.
C.
C++ allows static member function be of type const.
D.
Both A and B.

Your Answer: Option (Not Answered)

Correct Answer: Option D

Learn more problems on : OOPS Concepts

Discuss about this problem : Discuss in Forum


3.

Which of the following statement is correct?

A.
Only one parameter of a function can be a default parameter.
B.
Minimum one parameter of a function must be a default parameter.
C.
All the parameters of a function can be default parameters.
D.
No parameter of a function can be default.

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : Functions

Discuss about this problem : Discuss in Forum


4.

Which of the following statement is correct?

A.
The order of the default argument will be right to left.
B.
The order of the default argument will be left to right.
C.
The order of the default argument will be alternate.
D.
The order of the default argument will be random.

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Functions

Discuss about this problem : Discuss in Forum


5.

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; 
}

A.
The program will display 1.
B.
The program will display 2.
C.
The program will display 15.
D.
The program will go into an infinite loop.
E.
The program will report error on compilation.

Your Answer: Option (Not Answered)

Correct Answer: Option D

Learn more problems on : Functions

Discuss about this problem : Discuss in Forum


6.

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; 
}

A.
0
B.
5
C.
100
D.
-5
E.
None of these

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Functions

Discuss about this problem : Discuss in Forum


7.

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; 
}

A.
The program will print the output 0.
B.
The program will print the output 1.
C.
The program will print the output 2.
D.
The program will print the output garbage value.
E.
The program will report compile time error.

Your Answer: Option (Not Answered)

Correct Answer: Option E

Learn more problems on : Functions

Discuss about this problem : Discuss in Forum


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);
}

A.
The program will print the output 2 4.
B.
The program will print the output 20 40.
C.
The program will print the output 10 20.
D.
The program will print the output 20 4.50.
E.
The program will report compile time error.

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Functions

Discuss about this problem : Discuss in Forum


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; 
}

A.
The program will print the output M = 130.
B.
The program will print the output M = 195.
C.
The program will print the output M = -21.
D.
The program will print the output M = -61.
E.
The program will report compile time error.

Your Answer: Option (Not Answered)

Correct Answer: Option D

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> 
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; 
}

A.
0
B.
314
C.
314.0000
D.
200.0000

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Functions

Discuss about this problem : Discuss in Forum


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.

A.
Only 1 is correct.
B.
Only 2 is correct.
C.
Both 1 and 2 are correct.
D.
Both 1 and 2 are incorrect.

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : References

Discuss about this problem : Discuss in Forum


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; 
}

A.
It will result in a compile time error.
B.
The program will print the output 10 20.
C.
The program will print two garbage values.
D.
The program will print the address of variable x1 and y1.

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : References

Discuss about this problem : Discuss in Forum


13.

How many objects can be created from an abstract class?

A.
Zero
B.
One
C.
Two
D.
As many as we want

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Objects and Classes

Discuss about this problem : Discuss in Forum


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; 
}

A.
The program will print the output 0.
B.
The program will print the output 44.
C.
The program will print the output Garbage.
D.
The program will report compile time error.

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Objects and Classes

Discuss about this problem : Discuss in Forum


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; 
}

A.
45 22
B.
46 22
C.
45 23
D.
46 23

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Objects and Classes

Discuss about this problem : Discuss in Forum


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; 
}

A.
1 2
B.
10 20
C.
11 22
D.
Garbage Garbage
E.
The program will report compile time error.

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : Objects and Classes

Discuss about this problem : Discuss in Forum


17.

For automatic objects, constructors and destructors are called each time the objects

A.
enter and leave scope
B.
inherit parent class
C.
are constructed
D.
are destroyed

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Constructors and Destructors

Discuss about this problem : Discuss in Forum


18.

Copy constructor must receive its arguments by __________ .

A.
either pass-by-value or pass-by-reference
B.
only pass-by-value
C.
only pass-by-reference
D.
only pass by address

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 implicitly creates a default constructor when the programmer does not explicitly define at least one constructor for a class?

A.
Preprocessor
B.
Linker
C.
Loader
D.
Compiler

Your Answer: Option (Not Answered)

Correct Answer: Option D

Learn more problems on : Constructors and Destructors

Discuss about this problem : Discuss in Forum


20.

Which of the following statement is correct?

A.
A constructor of a derived class can access any public and protected member of the base class.
B.
Constructor cannot be inherited but the derived class can call them.
C.
A constructor of a derived class cannot access any public and protected member of the base class.
D.
Both A and B.

Your Answer: Option (Not Answered)

Correct Answer: Option D

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.