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 is correct about function overloading?
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 used to make an abstract class?
Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : OOPS Concepts
3.
What is correct about the static data member of a class?
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 a mechanism of static polymorphism?
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 function / type of function cannot be overloaded?
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 incorrect?
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>
class Base
{
public:
char S, A, M;
Base(char x, char y)
{
S = y - y;
A = x + x;
M = x * x;
}
Base(char, char y = 'A', char z = 'B')
{
S = y;
A = y + 1 - 1;
M = z - 1;
}
void Display(void)
{
cout<< S << " " << A << " " << M << endl;
}
};
class Derived : public Base
{
char x, y, z;
public:
Derived(char xx = 65, char yy = 66, char zz = 65): Base(x)
{
x = xx;
y = yy;
z = zz;
}
void Display(int n)
{
if(n)
Base::Display();
else
cout<< x << " " << y << " " << z << endl;
}
};
int main()
{
Derived objDev;
objDev.Display(0-1);
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>
#include<string.h>
class BixString
{
char x[50];
char y[50];
char z[50];
public:
BixString()
{ }
BixString(char* xx)
{
strcpy(x, xx);
strcpy(y, xx);
}
BixString(char *xx, char *yy = " C++", char *zz = " Programming!")
{
strcpy(z, xx);
strcat(z, yy);
strcat(z, zz);
}
void Display(void)
{
cout<< z << endl;
}
};
int main()
{
BixString objStr("Learn", " Java");
objStr.Display();
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 statements is correct?
- Pointer to a reference and reference to a pointer both are valid.
- When we use reference, we are actually referring to a referent.
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 statements is correct?
- An array of references is acceptable.
- We can also create a reference to a reference.
Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : References
11.
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
12.
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 : References
13.
Which of the following statement is correct about the program given below?
#include<iostream.h>
int main()
{
int x = 10;
int &y = x;
x = 25;
y = 50;
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
14.
Which of the following statements is correct when a class is inherited privately?
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 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;
}
Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : Objects and Classes
16.
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)
{
this->x = xx;
}
static void Display()
{
cout<< x ;
}
};
int IndiaBix::x = 0;
int main()
{
IndiaBix::SetData(22);
IndiaBix::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
17.
What happens when a class with parameterized constructors and having no default constructor is used in a program and we create an object that needs a zero-argument constructor?
Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : Constructors and Destructors
18.
Which constructor function is designed to copy objects of the same class type?
Your Answer: Option
(Not Answered)
Correct Answer: Option
Discuss about this problem : Discuss in Forum
Learn more problems on : Constructors and Destructors
19.
Destructors __________ for automatic objects if the program terminates with a call to function exit or function abort.
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:
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
*** 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