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 correctly describes overloading of functions?
Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : OOPS Concepts
2.
Which of the following is the correct class of the object cout?
Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : OOPS Concepts
3.
Which of the following cannot be used with the keyword virtual?
Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : OOPS Concepts
4.
Which of the following is not a type of constructor?
Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : OOPS Concepts
5.
Which of the following statement is correct?
Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : Functions
6.
What will be the output of the following program?
#include<iostream.h>
class TestDrive
{
int x;
public:
TestDrive(int xx)
{
x = xx;
}
int DriveIt(void);
};
int TestDrive::DriveIt(void)
{
static int value = 0;
int m;
m = x % 2;
x = x / 2;
if((x / 2)) DriveIt();
value = value + m * 10;
return value;
}
int main()
{
TestDrive TD(1234);
cout<< TD.DriveIt() * 10 << endl;
return 0;
}Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : Functions
7.
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;
}Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : Functions
8.
Functions can be declared to return a reference type. There are reasons to make such a declaration/Which of the following reasons are correct?
- The information being returned is a large enough object that returning a reference is more efficient than returning a copy.
- The type of the function must be a R-value.
Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : References
9.
Which of the following statements is correct?
- A reference is not a constant pointer.
- A referenced is automatically de-referenced.
Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : References
10.
Which of the following statement is correct about the program given below?
#include<iostream.h>
int main()
{
int x = 80;
int &y = x;
x++;
cout << x << " " << --y;
return 0;
}Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : References
11.
Which of the following statement is correct about the program given below?
#include<iostream.h>
class IndiaBix
{
int a, b, c;
public:
void SetValue(int x, int y ,int z)
{
a = x;
b = y;
c = z;
}
void Display()
{
cout<< a << " " << b << " " << c;
}
};
int main()
{
IndiaBix objBix;
int x = 2;
int &y = x;
y = 5;
objBix.SetValue(x, ++y, x + y);
objBix.Display();
return 0;
}Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : References
12.
Which of the following statement is correct about the program given below?
#include<iostream.h>
class IndiaBix
{
int x, y;
public:
void SetValue(int &xx, int &yy)
{
x = xx++;
y = yy;
cout<< xx << " " << yy;
}
};
int main()
{
int x = 10;
int &y = x;
IndiaBix objBix;
objBix.SetValue(x , y);
return 0;
}Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : References
13.
Constructor is executed when _____.
Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : Objects and Classes
14.
What will be the output of the following program?
#include<iostream.h>
class BixBase
{
public:
float x;
};
class BixDerived : public BixBase
{
public:
char ch;
void Process()
{
ch = (int)((x=12.0)/3.0);
}
void Display()
{
cout<< (int)ch;
}
};
int main()
{
class BixDerived *objDev = new BixDerived;
objDev->Process();
objDev->Display();
return 0;
}Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : Objects and Classes
15.
It is a __________ error to pass arguments to a destructor.
Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : Constructors and Destructors
16.
Destructor has the same name as the constructor and it is preceded by ______ .
Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : Constructors and Destructors
17.
A __________ is a constructor that either has no parameters, or if it has parameters, all the parameters have default values.
Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : Constructors and Destructors
18.
If the copy constructor receives its arguments by value, the copy constructor would
Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : Constructors and Destructors
19.
What will be the output of the following program?
#include<iostream.h>
class BixBase
{
public:
int x, y;
BixBase(int xx = 0, int yy = 5)
{
x = ++xx;
y = --yy;
}
void Display()
{
cout<< --y;
}
~BixBase(){}
};
class BixDerived : public BixBase
{
public:
void Increment()
{
y++;
}
void Display()
{
cout<< --y;
}
};
int main()
{
BixDerived objBix;
objBix.Increment();
objBix.Display();
return 0;
}Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : Constructors and Destructors
20.
What will be the output of the following program?
#include<iostream.h>
class BixBase
{
public:
BixBase()
{
cout<< "Base OK. ";
}
virtual ~BixBase()
{
cout<< "Base DEL. ";
}
};
class BixDerived: public BixBase
{
public:
BixDerived()
{
cout<< "Derived OK. ";
}
~BixDerived()
{
cout<< "Derived DEL. ";
}
};
int main()
{
BixBase *basePtr = new BixDerived();
delete basePtr;
return 0;
}Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : Constructors and Destructors
*** END OF THE TEST ***
Time Left: 00:29:56
Post your test result / feedback here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers