CoCubes C++ Question and Answers Quiz-1

Question 1

Time: 00:00:00
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?

Compile-time error.

Compile-time error.

Preprocessing error.

Preprocessing error.

Runtime error.

Runtime error.

Runtime exception.

Runtime exception.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 2

Time: 00:00:00
Which of the following statement is correct?

A destructor has the same name as the class in which it is present.

A destructor has the same name as the class in which it is present.

A destructor has a different name than the class in which it is present.

A destructor has a different name than the class in which it is present.

A destructor always returns an integer.

A destructor always returns an integer.

A destructor can be overloaded.

A destructor can be overloaded.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 3

Time: 00:00:00
A __________ is a constructor that either has no parameters or if it has parameters, all the parameters have default values.

default constructor

default constructor

copy constructor

copy constructor

Both A and B

Both A and B

None of these

None of these

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Copy Constructor always required a reference of the same object. So if it is not having any parameter then it cant be copy constructor. So it is the default constructor that bears the values.

Start

Question 4

Time: 00:00:00
Which of the following statements about virtual base classes is correct?

It is used to provide multiple inheritances.

It is used to provide multiple inheritances.

It is used to avoid multiple copies of the base class in derived class.

It is used to avoid multiple copies of the base class in derived class.

It is used to allow multiple copies of the base class in a derived class.

It is used to allow multiple copies of the base class in a derived class.

It allows private members of the base class to be inherited in the derived class.

It allows private members of the base class to be inherited in the derived class.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Virtual base classes are used in virtual inheritance in a way of preventing multiple “instances” of a given class appearing in an inheritance hierarchy when using multiple inheritances.

Virtual base classes are used in virtual inheritance in a way of preventing multiple “instances” of a given class appearing in an inheritance hierarchy when using multiple inheritances.

Start

Question 5

Time: 00:00:00
Which of the following statement will be correct if the function has three arguments passed to it?

The trailing argument will be the default argument.

The trailing argument will be the default argument.

The first argument will be the default argument.

The first argument will be the default argument.

The middle argument will be the default argument.

The middle argument will be the default argument.

All the argument will be the default argument.

All the argument will be the default argument.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 6

Time: 00:00:00
Which of the following function declaration is/are incorrect?

int Sum(int a, int b = 2, int c = 3);

int Sum(int a, int b = 2, int c = 3);

int Sum(int a = 5, int b);

int Sum(int a = 5, int b);

int Sum(int a = 0, int b, int c = 3);

int Sum(int a = 0, int b, int c = 3);

Both B and C are incorrect.

Both B and C are incorrect.

All are correct.

All are correct.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 7

Time: 00:00:00
Which of the following statement is incorrect?

The default value for an argument can be a global constant.

The default value for an argument can be a global constant.

The default arguments are given in the function prototype.

The default arguments are given in the function prototype.

The compiler uses the prototype information to build a call, not the function definition.

The compiler uses the prototype information to build a call, not the function definition.

The default arguments are given in the function prototype and should be repeated in the function definition.

The default arguments are given in the function prototype and should be repeated in the function definition.

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 8

Time: 00:00:00

What will be the output of the following program?

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

10

10

20

20

30

30

40

40

Compilation fails

Compilation fails

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 9

Time: 00:00:00
What will be the output of the following program?

#include
int main()
{
float Amount;
float Calculate(float P = 5.0, int N = 2, float R = 2.0);
Amount = Calculate();
cout<< Amount << endl;
return 0;
}

float Calculate(float P, int N, float R)
{
int Year = 1;
float Sum = 1 ;
Sum = Sum * (1 + P * ++N * R);
Year = (int)(Year + Sum);
return Year;
}

21

21

22

22

31

31

32

32

None of these

None of these

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 10

Time: 00:00:00
What will be the output of the following program?

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

30 10 20

30 10 20

Garbage 10 20

Garbage 10 20

40 50 20

40 50 20

20 40 50

20 40 50

40 Garbage Garbage

40 Garbage Garbage

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

["0","40","60","80","100"]
["Need more practice! \r\n","Keep trying! \r\n","Not bad! \r\n","Good work! \r\n","Perfect! \r\n"]

Personalized Analytics only Availble for Logged in users

Analytics below shows your performance in various Mocks on PrepInsta

Your average Analytics for this Quiz

Rank

-

Percentile

0%

Completed

0/10

Accuracy

0%

Get Prepinsta Prime

Get all 200+ courses offered by Prepinsta

Never Miss an OffCampus Update

Get OffCampus Updates on Social Media from PrepInsta

Follow us on our Media Handles, we post out OffCampus drives on our Instagram, Telegram, Discord, Whatsdapp etc.

Get Hiring Updates
Amazon,Google,Delottie & 30+companies are hiring ! Get hiring Updates right in your inbox from PrepInsta

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others.

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others.

Get PrepInsta Prime Subscription

Get access to all the courses that PrepInsta offers, check the out below -

Companies

TCS, Cognizant, Delloite, Infosys, Wipro, CoCubes, KPMG, Amazone, ZS Associates, Accenture, Congnizant & other 50+ companies

Programming

Data Structures, Top 500 Codes, C, C++, Java Python & other 10+ subjects

Skills

Full Stack Web Development, Data Science, Machine Learning, AWS Cloud, & other 10+ skills and 20+ projects

Comments