To pass the CPA-21-02 exam, you must have a solid preparation. Fortunately, there is help in the form of online CPA-21-02 practice exam software. The program is easy to use and will prepare you for the actual exam. Using the practice exam software will enable you to identify your weak areas.
Quuestion: 1
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;
}
};
A. public
B. private
C. protected
D. None of these
Answer: C
Quuestion: 2
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string> using namespace std; int main()
{
string s1[]= {'How' , 'to' };
s1[0].swap(s1[1]);
for (int i=0; i<2; i++) { cout << s1[i];
}
return( 0 );
}
A. It prints: Hoto
B. It prints: toHow
C. It prints: Ht
D. It prints: to
Answer: B
Quuestion: 3
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
Answer: B
Quuestion: 4
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;
}
A. 3
B. 5
C. 4
D. 5
Answer: C
Quuestion: 5
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;
}
A. It will print: Helloworld
B. It will print: Hello
C. It will print: world
D. It will print: 0
Answer: A
Quuestion: 6
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''
B. It prints:''3210''
C. It prints: ''3210?1''
D. None of these
Answer: A
Quuestion: 7
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;
}
int main(){ 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.
Answer: A
Next Page
No comments yet