Infosys Certified CPP Programmer
Practice with real exam-pattern questions for Infosys Certified CPP Programmer. Each question includes a detailed explanation to help you understand the concept, not just memorise the answer. Try 10 questions free — no login required.
Full question bank for this exam + 1,357+ others. Cancel anytime.
Join Premium10 Infosys Certified CPP Programmer practice questions with answers
Real Lex exam-pattern multiple-choice questions for the Infosys Certified CPP Programmer certification. Each question includes the correct answer. The full question bank is available to Premium members.
- Question 1
Predict the output of following program.
class ThisPointer {
private:
int x;
public:
ThisPointer(){
x = 100;
}
void deletion(){
delete this;
}
void display(){
cout << "x = " << x; }
};
int main() {
ThisPointer tp;
tp.deletion();
tp.display();
return 0;
}- ✓x=100Correct
- BCompile time error
- CUndefined Behavior at run time like "Segmentation Fault" will be displayed in the console
- Dx=0
- Question 2
Predict the output of following program.
class BaseClass {};
class DerivedClass: public BaseClass {};
int main() {
DerivedClass d;
try {
throw d;
}
catch (...){
cout << "Caught default Exception";
}
catch(BaseClass b) {
cout<<"Caught BaseClass Exception ";
}
catch(DerivedClass d) {
cout<<"Caught DerivedClass Exception ";
}
return 0;
}- ✓Caught BaseClass ExceptionCorrect
- BCaught DerivedClass Exception
- CCaught default Exception
- DCompile time error
- Question 3
Predict the output for the following program. class Base {}; class Derived:public Base {}; int main() { Base *bp = new Derived; Derived *dp = new Base; }
- ✓No outputCorrect
- BCompiler Error in line “Derived *dp = new Base;”
- CCompiler Error in line “Base *bp = new Derived;”
- DRuntime Error
- Question 4
Spot the possible errors in the following program
Line - 1 class Base {
Line - 2 void display(){
Line - 3 cout << "Base class - display";
Line - 4 }
Line - 5 };
Line - 6 class Derived : protected Base{
Line - 7 public:
Line - 8 void display(){
Line - 9 cout << "Derived class - display";
Line - 10 }
Line - 11 };
Line - 12 int main() {
Line - 13 Base* b = new Derived;
Line - 14 b.display();
Line - 15 return 0;
Line - 16 }- ✓Line - 2, 6, 13, 14Correct
- BLine - 2, 6, 14
- CLine - 2, 13, 14
- DLine - 6, 13, 14
- Question 5
Predict the output for the following program
class Employee {
public:
Employee(){
cout << "Constructor of Employee Class" << endl;
}
~Employee(){
cout << "Destructor of Employee Class" << endl;
}
};
class Trainee : public Employee {
public:
Trainee(){
cout << "Constructor of Trainee Class" << endl;
}
~Trainee(){
cout << "Destructor of Trainee Class" << endl;
}
};
int main() {
Trainee* t = new Trainee;
free(t);
}- ✓Constructor of Trainee Class Constructor of Employee ClassCorrect
- BConstructor of Employee Class Constructor of Trainee Class Destructor of Trainee Class Destructor of Employee Class
- CConstructor of Employee Class Constructor of Trainee Class
- DConstructor of Employee Class Constructor of Trainee Class Destructor of Employee Class Destructor of Trainee Class
- Question 6
Below code is not working. What could be the possible error?
class base {
public:
base() {
cout<<"Constructing base \n";
}
~base() {
cout<<"Destructing base \n";
}
};
class derived: public base {
public:
derived() {
cout<<"Constructing derived \n";
}
~derived() {
cout<<"Destructing derived \n";
}
};
int main(void) {
derived d;
base* b = d;
return 0;
}- ✓base* initialization should be done using new operatorCorrect
- Bderived cannot be converted to base* in initialization
- CNo error
- DNone of the above
- Question 7
Predict the output for the following program
class base {
public:
base() {
cout<<"Constructing base \n";
}
~base() {
cout<<"Destructing base \n";
}
};
class derived: public base {
public:
derived() {
cout<<"Constructing derived \n";
}
~derived() {
cout<<"Destructing derived \n";
}
};
int main(void) {
base* b = new derived;
delete b;
return 0;
}- ✓Constructing base Destructing baseCorrect
- BConstructing derived Destructing derived
- CConstructing base Constructing derived Destructing derived Destructing base
- DConstructing base Constructing derived Destructing base
- Question 8
Predict the output for the following program
int main() {
try {
throw 'a';
}
catch (int x) {
cout << "Caught a";
}
return 0;
}- ✓Caught aCorrect
- BNo output
- CCompile time error - No valid exception handler
- DTerminate called after throwing an instance of 'char'
- Question 9
Predict the output for the following program
class LivingThing {
public:
LivingThing(){
cout << "Constructor of LivingThing Class" << endl;
}
~LivingThing(){
cout << "Destructor of LivingThing Class" << endl;
}
};
class Animal : public LivingThing {
public:
Animal(){
cout << "Constructor of Animal Class" << endl;
}
~Animal(){
cout << "Destructor of Animal Class" << endl;
}
};
class Reptile : public LivingThing {
public:
Reptile(){
cout << "Constructor of Reptile Class" << endl;
}
~Reptile(){
cout << "Destructor of Reptile Class" << endl;
}
};
class Snake : public Animal, public Reptile {
public:
Snake(){
cout << "Constructor of Snake Class" << endl;
}
~Snake(){
cout << "Destructor of Snake Class" << endl;
}
};
int main() {
Snake* s = new Snake;
}- ✓Constructor of LivingThing Class Constructor of Animal Class Constructor of LivingThing Class Constructor of Reptile Class Constructor of Snake ClassCorrect
- BConstructor of LivingThing Class Constructor of Animal Class Constructor of LivingThing Class Constructor of Reptile Class Constructor of Snake Class Destructor of Snake Class Destructor of Reptile Class Destructor of LivingThing Class Destructor of Animal Class Destructor of LivingThing Class
- CConstructor of LivingThing Class Constructor of Animal Class Constructor of Reptile Class Constructor of Snake Class
- DConstructor of LivingThing Class Constructor of Animal Class Constructor of LivingThing Class Constructor of Reptile Class Constructor of Snake Class Destructor of LivingThing Class Destructor of Animal Class Destructor of LivingThing Class Destructor of Reptile Class Destructor of Snake Class
- Question 10
Consider the below program, in which line, error will be thrown?
class Base {
public :
int x, y;
public:
Base(int i, int j){
x = i;
y = j;
}
};
class Derived : public Base {
public:
Derived(int i, int j):x(i), y(j) {} // Line 1
void print() {
cout << x <<" "<< y; // Line 2
}
};
int main(void){
Derived d(10, 10); // Line 3
d.print();
return 0;
}- ✓Line 1Correct
- BLine 2
- CLine 3
- DNo error, code will work fine
More in Engineering Academy
Infosys Certified NX PLM-1 Engineering Author
Infosys Certified SON Associate
Infosys Certified Medical Devices Specialist
Pay once. Clear every cert this year.
One subscription, full Telegram channel access, every PDF posted during your membership.
- Full access to all 1,357+ certifications
- Monthly updated question banks
- Telegram private channel access
- Cancel anytime
- Everything in Monthly
- Save ₹2,100 vs monthly billing
- Priority answer key requests
- Best for increasing DQ score fast
- Everything in Quarterly
- Lifetime channel access — no renewals
- All future certifications included
- Priority response from admin team
Common questions, straight answers.
A monthly-updated Telegram channel where we post real exam-pattern question banks and detailed answer keys for 1,357+ Infosys Lex certifications. You join once, you get every PDF posted during your membership.
Right after payment on our Graphy page, you'll receive a private invite link to the Telegram channel. Access is instant — usually under 30 seconds.
We compile question banks from the actual Lex test pattern, sourced and verified by 180K+ community members who've recently cleared these exams. Match rate is consistently 85–95%.
Every single month. When Infosys rolls out new versions of certifications, we post updated dumps within 7–10 days. You'll see channel activity weekly.
Clearing certifications is one of the highest-weighted DQ factors. Members typically clear 3–5 certifications in their first 3 months, which moves DQ scores up by a full band.