What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;class BaseC{public:int *ptr;BaseC() { ptr = new int(10);}BaseC(int i) { ptr = new int(i); }~BaseC() { delete ptr; }};void fun(BaseC x);int main(){BaseC *o = new BaseC(5);fun(*o);}void fun(BaseC x) {cout << "Hello:"<<*x.ptr;}
Answer(s): C
What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;class First{public:virtual void Print(){ cout<<"from First";}};class Second:public First{public:void Print(){ cout<< "from Second";}};void fun(First *obj);int main(){First FirstObject;fun(&FirstObject);Second SecondObject;fun(&SecondObject);}void fun(First *obj){obj?>Print();}
What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;int min(int a, int b);int main(){int min(int,int);int b;b = min(10,20);cout << b;return 0;}int min(int a, int b){return(b);}
Answer(s): A
What happens when you attempt to compile and run the following code?#include <iostream>using namespace std;int main(){union un{int x;char c;};union un u1 = {10};union un u2 = {'a'};union un u3 = {20, 'a'};cout<<u1.x;cout<<u2.c;cout<<u3.c;return 0;}
Answer(s): D
Post your Comments and Discuss C++ Institute CPA-21-02 exam with other Community members:
Subash commented on October 21, 2024 I am planning to take this exam. Are these 257 questions enough to clear it? Also, does each section have a passing percentage, or is it based on the overall ? INDIA upvote
Our website is free, but we have to fight against bots and content theft. We're sorry for the inconvenience caused by these security measures. You can access the rest of the CPA-21-02 content, but please register or login to continue.