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



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 statement is correct about the program given below?

#include<iostream.h> 
class BixData
{
    int x, y, z; 
    public:
    BixData(int xx, int yy, int zz)
    {
        x = ++xx;
        y = ++yy;
        z = ++zz;
    }
    void Show()
    {
        cout<< "" << x++ << " " << y++ << " " << z++;
    } 
}; 
int main()
{
    BixData objData(1, 2, 3);
    objData.Show();
    return 0; 
}

A.
The program will print the output 1 2 3.
B.
The program will print the output 2 3 4 .
C.
The program will print the output 4 5 6.
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


2.

Which of the following statement is correct about destructors?

A.
A destructor has void return type.
B.
A destructor has integer return type.
C.
A destructor has no return type.
D.
A destructors return type is always same as that of main().

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : Constructors and Destructors

Discuss about this problem : Discuss in Forum


3.

Which of the following never requires any arguments?

A.
Member function
B.
Friend function
C.
Default constructor
D.
const function

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : Constructors and Destructors

Discuss about this problem : Discuss in Forum


4.

Which of the following cannot be used with the keyword virtual?

A.
class
B.
member functions
C.
constructor
D.
destructor

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : OOPS Concepts

Discuss about this problem : Discuss in Forum


5.

Which of the following statement is correct?

A.
Class is an instance of object.
B.
Object is an instance of a class.
C.
Class is an instance of data type.
D.
Object is an instance of data type.

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : OOPS Concepts

Discuss about this problem : Discuss in Forum


6.

Which inheritance type is used in the class given below?
class A : public X, public Y
{}

A.
Multilevel inheritance
B.
Multiple inheritance
C.
Hybrid inheritance
D.
Hierarchical Inheritance

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : OOPS Concepts

Discuss about this problem : Discuss in Forum


7.

In which of the following a virtual call is resolved at the time of compilation?

A.
From inside the destructor.
B.
From inside the constructor.
C.
From inside the main().
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


8.

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


9.

Which of the following correctly describes overloading of functions?

A.
Virtual polymorphism
B.
Transient polymorphism
C.
Ad-hoc polymorphism
D.
Pseudo polymorphism

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : OOPS Concepts

Discuss about this problem : Discuss in Forum


10.

Which of the following is correct about the statements given below?

  1. All operators can be overloaded in C++.
  2. We can change the basic meaning of an operator in C++.

A.
Only I is true.
B.
Both I and II are false.
C.
Only II is true.
D.
Both I and II are true.

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : OOPS Concepts

Discuss about this problem : Discuss in Forum


11.

Which of the following concepts of OOPS means exposing only necessary information to client?

A.
Encapsulation
B.
Abstraction
C.
Data hiding
D.
Data binding

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : OOPS Concepts

Discuss about this problem : Discuss in Forum


12.

Which of the following problem causes an exception?

A.
Missing semicolon in statement in main().
B.
A problem in calling function.
C.
A syntax error.
D.
A run-time error.

Your Answer: Option (Not Answered)

Correct Answer: Option D

Learn more problems on : OOPS Concepts

Discuss about this problem : Discuss in Forum


13.

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

#include<iostream.h> 
class Bix
{
      int x; 
    public:
      Bix();
      void Show() const;
      ~Bix(){}
};
Bix::Bix()
{
    x = 5;
}
void Bix::Show() const
{
    cout<< x;
}
int main()
{
    Bix objB;
    objB.Show();
    return 0; 
}

A.
The program will print the output 5.
B.
The program will print the output Garbage-value.
C.
The program will report compile time error.
D.
The program will report runtime error.

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Constructors and Destructors

Discuss about this problem : Discuss in Forum


14.

Which of the following statement is correct?

A.
C++ enables to define functions that take constants as an argument.
B.
We cannot change the argument of the function that that are declared as constant.
C.
Both A and B.
D.
We cannot use the constant while defining the function.

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : Functions

Discuss about this problem : Discuss in Forum


15.

What will be the output of the following program?

#include<iostream.h> 
class IndiaBix
{
    public: 
    int x, y;
    IndiaBix(int xx = 10, int yy = 20)
    {
        x = xx;
        y = yy; 
    }
    void Exchange(int *, int *);
};
int main()
{
    IndiaBix objA(30, 40); 
    IndiaBix objB(50); 
    objA.Exchange(&objA.x, &objB.y); 
    cout<< objA.x << " " << objB.y << endl; 
    return 0;
}
void IndiaBix::Exchange(int *x, int *y)
{
    int t;
    t  = *x;
    *x = *y;
    *y = t ; 
}

A.
20 10
B.
30 20
C.
20 30
D.
30 40
E.
50 30

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : Functions

Discuss about this problem : Discuss in Forum


16.

What will be the output of the following program?

#include<iostream.h>
double BixFunction(double, double, double = 0, double = 0, double = 0);
int main()
{
    double d = 2.3;
    cout<< BixFunction(d, 7) << " ";
    cout<< BixFunction(d, 7, 6) << endl;
    return 0; 
}
double BixFunction(double x, double p, double q, double r, double s)
{
    return p +(q +(r + s * x)* x) * x;
}

A.
7 20
B.
7 19.8
C.
7 Garbage
D.
7 20.8

Your Answer: Option (Not Answered)

Correct Answer: Option D

Learn more problems on : Functions

Discuss about this problem : Discuss in Forum


17.

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

#include<iostream.h> 
class PowerFinder
{
    public:
    void Power(int x = 1, int y = 1)
    {
        int P = 1, i = 1;
        while(++i <= y)
        {
            P *= x;
        }
        cout<< P << endl; 
    } 
};
int main()
{
    PowerFinder FP; 
    FP.Power(2, 6); 
    return 0;
}

A.
The program will print the output 12.
B.
The program will print the output 16.
C.
The program will print the output 32.
D.
The program will print the output 36.
E.
The program will execute infinite time.

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : Functions

Discuss about this problem : Discuss in Forum


18.

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

A.
It will result in a compile time error.
B.
The program will print the output 1.
C.
The program will print the output 2.
D.
The program will print the output 3.

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : References

Discuss about this problem : Discuss in Forum


19.

Which of the following can access private data members or member functions of a class?

A.
Any function in the program.
B.
All global functions in the program.
C.
Any member function of that class.
D.
Only public member functions of that class.

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : Objects and Classes

Discuss about this problem : Discuss in Forum


20.

Which of the following can be overloaded?

A.
Object
B.
Functions
C.
Operators
D.
Both B and C

Your Answer: Option (Not Answered)

Correct Answer: Option D

Learn more problems on : Objects and Classes

Discuss about this problem : Discuss in Forum


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