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 access specifier is used as a default in a class definition?
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 function / types of function cannot have default parameters?
Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : Functions
3.
Which of the following statement is incorrect?
Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : Functions
4.
Which of the following function declaration is/are incorrect?
Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : Functions
5.
What will be the output of the following program?
#include<iostream.h>
typedef void(*FunPtr)(int);
int Look(int = 10, int = 20);
void Note(int);
int main()
{
FunPtr ptr = Note;
(*ptr)(30);
return 0;
}
int Look(int x, int y)
{
return(x + y % 20);
}
void Note(int x)
{
cout<< Look(x) << endl;
}
Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : Functions
6.
Which of the following statement is correct about the program given below?
#include<iostream.h>
static int Result;
class India
{
public:
void Change(int x = 10, int y = 20, int z = 30)
{
cout<< x + y + z;
}
void Display(int x = 40, float y = 50.00)
{
Result = x % x;
cout<< Result;
}
};
class Bix
{
int x, y;
public:
void Change(int x, int y = 50)
{
cout<< x + y;
}
};
class IndiaBix: public India, public Bix
{
public:
void Display(int x = 10, int xx = 100, int xxx = 1000)
{
Result = x + xx % x * x;
cout<< Result ;
}
};
int main()
{
IndiaBix objBix;
objBix.India::Display(10, 20.00);
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>
void MyFunction(int a, int b = 40)
{
cout<< " a = "<< a << " b = " << b << endl;
}
int main()
{
MyFunction(20, 30);
return 0;
}
Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : Functions
8.
What will be the output of the following program?
#include<iostream.h>
class BaseCounter
{
protected:
long int count;
public:
void CountIt(int x, int y = 10, int z = 20)
{
count = 0;
cout<< x << " " << y << " " << z << endl;
}
BaseCounter()
{
count = 0;
}
BaseCounter(int x)
{
count = x ;
}
};
class DerivedCounter: public BaseCounter
{
public:
DerivedCounter()
{ }
DerivedCounter(int x): BaseCounter(x)
{ }
};
int main()
{
DerivedCounter objDC(30);
objDC.CountIt(40, 50);
return 0;
}
Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : Functions
9.
Which of the following statement is correct about the program given below?
#include<iostream.h>
struct MyStructure
{
class MyClass
{
public:
void Display(int x, float y = 97.50, char ch = 'a')
{
cout<< x << " " << y << " " << ch;
}
}Cls;
}Struc;
int main()
{
Struc.Cls.Display(12, 'b');
return 0;
}
Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : Functions
10.
Which of the following statement is correct about the references?
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 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
12.
Which of the following statement is correct about the program given below?
#include<iostream.h>
int main()
{
int m = 2, n = 6;
int &x = m;
int &y = n;
m = x++;
x = m++;
n = y++;
y = n++;
cout<< m << " " << n;
return 0;
}
Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : References
13.
Which of the following statement is correct about the program given below?
#include<iostream.h>
int BixFunction(int m)
{
m *= m;
return((10)*(m /= m));
}
int main()
{
int c = 9, *d = &c, e;
int &z = e;
e = BixFunction(c-- % 3 ? ++*d :(*d *= *d));
z = z + e / 10;
cout<< c << " " << e;
return 0;
}
Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : References
14.
Which of the following statements is incorrect?
Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : Objects and Classes
15.
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 : Constructors and Destructors
16.
To ensure that every object in the array receives a destructor call, always delete memory allocated as an array with operator __________ .
Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : Constructors and Destructors
17.
A function with the same name as the class, but preceded with a tilde character (~) is called __________ of that class.
Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : Constructors and Destructors
18.
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 : Constructors and Destructors
19.
If the programmer does not explicitly provide a destructor, then which of the following creates an empty destructor?
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 out of the following program?
#include<iostream.h>
class BixBase
{
public:
int x, y;
public:
BixBase(int xx = 0, int yy = 0)
{
x = xx;
y = yy;
}
};
class BixDerived : public BixBase
{
private:
BixBase objBase;
public:
BixDerived(int xx, int yy) : BixBase(xx), objBase(yy)
{
cout << this->x << " "
<< this->y << " "
<< objBase.x << " "
<< objBase.y << " ";
}
~BixDerived()
{ }
};
int main()
{
BixDerived objDev(11, 22);
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