Free Practice Test

Free CPA-21-02 Practice Test Questions and Answers (2026) | Cert Empire

C++ Institute CPA 21 02

View Mode
Q: 1
What happens when you attempt to compile and run the following code? #include using namespace std; class BaseClass { public: int *ptr; BaseClass(int i) { ptr = new int(i); } ~BaseClass() { delete ptr; delete ptr;} void Print() { cout << *ptr; } }; void fun(BaseClass x); int main() { BaseClass o(10); fun(o); o.Print(); } void fun(BaseClass x) { cout << "Hello:"; }
Options
Q: 2
What happens when you attempt to compile and run the following code? #include using namespace std; class A { public : void print() { cout << "A "; } }; class B { public : void print() { cout << "B "; } }; int main() { B sc[2]; B *bc = (B*)sc; for (int i=0; iprint(); return 0; }
Options
Q: 3
What happens when you attempt to compile and run the following code? C++ Institute CPA 21 02 question
Options
Q: 4
Which of the following is a user defined data type? 1: struct person { char name[20]; int age; }; 2: int l=2; 3: enum color {red,blue, green};
Options
Q: 5
What happens when you attempt to compile and run the following code? C++ Institute CPA 21 02 question
Options
Q: 6
What happens when you attempt to compile and run the following code? #include using namespace std; int main (int argc, const char * argv[]) { int tab[5]={1,2,3}; for (int i=0; i<5; i++) cout <<tab[i]; return 0; }
Options
Q: 7
What happens when you attempt to compile and run the following code? #include using namespace std; int main() { const char *s; char str[] = "Hello"; s = str; while(*s) { cout << *s++; } return 0; }
Options
Q: 8
What happens when you attempt to compile and run the following code? #include #include using namespace std; int main() { string s1[]= {"H" , "t" }; string s; for (int i=0; i<2; i++) { s = s1[i]; s.insert(1,"o"); cout << s; } return( 0 ); }
Options
Q: 9
What happens when you attempt to compile and run the following code? C++ Institute CPA 21 02 question
Options
Q: 10
Which code, inserted at line 18, generates the output "AB" #include using namespace std; class A { public: void Print(){ cout<< "A";} void Print2(){ cout<< "a";} }; class B:public A { public: void Print(){ cout<< "B";} void Print2(){ cout<< "b";} }; int main() { B ob2; //insert code here ob2.Print(); }
Options
Question 1 of 10

Scroll to Top

FLASH OFFER

Days
Hours
Minutes
Seconds

avail 10% DISCOUNT on YOUR PURCHASE