Exam Code : CPA-CPP
Exam Name : CPA - C++ Certified Associate Programmer (CPA-21-02)
Vendor Name :
"CPP-Institute"
CPA-CPP Dumps CPA-CPP Braindumps
CPA-CPP Real Questions CPA-CPP Practice Test CPA-CPP Actual Questions
killexams.com CPP-Institute CPA-CPP
CPA - C++ Certified Associate Programmer (CPA-21-02)
https://killexams.com/pass4sure/exam-detail/CPA-CPP
What happens when you attempt to compile and run the following code?
#include <iostream> 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; i<2;i++) (bc++)->print(); return 0;
}
It prints: A A
It prints: B B
It prints: A B
It prints: B A
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string> using namespace std; class complex{ double re;
double im; public:
complex() : re(1),im(0.4) {} bool operator==(complex &t);
};
bool complex::operator == (complex &t){ if((this?>re == t.re) && (this?>im == t.im)) return true;
else
return false;
}
complex c1,c2; if (c1==c2) cout << "OK"; else {
cout << "ERROR";
}
}
A. It prints: OK
B. It prints: ERROR
C. Compilation error
D. Runtime error.
What happens when you attempt to compile and run the following code?
#include <iostream> using namespace std; int main()
{
int i = 4; while(i >= 0) { cout<<i;
i??;
}
return 0;
}
A. It prints:”43210”
int main(){
It prints:”3210”
It prints: ”3210?1”
None of these
What will happen when you attempt to compile and run the following code?
#include <iostream> using namespace std;
#define A 1 int main()
{
#if A cout<<"Hello";
#endif cout<<"world"; return 0;
}
It will print: Helloworld
It will print: Hello
It will print: world
It will print: 0
What will be the output of the program?
#include <iostream>
#include <string> using namespace std; int fun(int);
int main()
{
float k=3; k = fun(k); cout<<k; return 0;
}
int fun(int i)
{ i++;
return i;
}
3
5
4
What happens when you attempt to compile and run the following code?
#include <iostream> using namespace std; int main()
{
const char *s;
char str[] = "Hello"; s = str;
while(*s) { cout << *s++;
}
return 0;
}
A. It prints: el
B. It prints: Hello
C. It prints: H
D. It prints: o
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string> using namespace std; int main()
5
{
string s1[]= {"How" , "to" };
s1[0].swap(s1[1]);
for (int i=0; i<2; i++) { cout << s1[i];
}
return( 0 );
}
It prints: Hoto
It prints: toHow
It prints: Ht
It prints: to
What will variable "y" be in class B? class A {
int x; protected: int y; public: int age;
};
class B : public A { string name;
public:
void Print() {
cout << name << age;
}
};
public
private
protected
None of these