Real CPA-21-02 dumps Accurate Questions and Answers with Free and Fast Updates
Real CPA-21-02 Quesions Pass Certification Exams Easily
NEW QUESTION # 46
What will happen when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main (int argc, const char * argv[])
{
enum state { ok, error, warning};
enum state s1, s2, s3;
s1 = ok;
s2 = warning;
s3 = error;
s4 = ok;
cout << s1<< s2<< s3;
return 0;
}
- A. It will print:"123"
- B. It will print:"132"
- C. It will print:"021"
- D. compilation error
Answer: D
NEW QUESTION # 47
Which of the following structures are correct?
1:
struct s1{
int x;
char c;
};
2:
struct s2{
float f;
struct s2 *s;
};
3:
struct s3{
float f;
in i;
}
- A. 0
- B. 1
- C. 2
- D. All of these
Answer: B,C
NEW QUESTION # 48
What happens when you attempt to compile and run the following code?
#include <iostream>
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:";
}
- A. It prints: Hello:
- B. Runtime error.
- C. It prints: Hello:1
- D. It prints: 10
Answer: B
NEW QUESTION # 49
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
class A
{
public:
virtual void Print(){ cout<<"A";}
};
class B:public A
{
public:
virtual void Print(){ cout<< "B";}
};
int main()
{
A *obj;
A ob1;
obj = &ob1;
obj?>Print();
B ob2;
obj = &ob2;
obj?>Print();
}
- A. It prints: AA
- B. It prints: BB
- C. It prints: BA
- D. It prints: AB
Answer: D
NEW QUESTION # 50
Which line of code inserted instead of the comment will make the following code run properly without causing memory leaks?
- A. ~Base() { delete ptr; }
- B. ~Base() ( delete this; }
- C. no additional code is needed
- D. ~Base() { delete ptr; delete ptr; }
Answer: A
NEW QUESTION # 51
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main (int argc, const char * argv[])
{
int x,y;
union t
{
char tab[2];
int i;
};
union t u;
u.tab[0] = 1;
u.tab[1] = 2;
u.i = 0;
x = u.tab[0];
y = u.tab[1];
cout << x << "," << y << "," << u.i;
return 0;
}
- A. compilation fails
- B. It prints: 1,2,0
- C. It prints: 0,0,0
- D. None of these
Answer: C
NEW QUESTION # 52
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int fun(int x) {
return 2*x;
}
int main(){
int i;
i = fun(0.5) || fun(0);
cout << i;
return 0;
}
- A. It prints: 1
- B. Compilation error
- C. It prints: 0
- D. It prints: -1
Answer: C
NEW QUESTION # 53
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
struct Person {
string name;
int age;
};
class First
{
Person *person;
public:
First() {person = new Person;
person?>name = "John";
person?>age = 30;
}
void Print(){
cout<<person?>name << " "<< person?>age;
}
};
int main()
{
First t;
t.Print();
}
- A. It prints: John 30John 30
- B. It prints: John
- C. It prints: 30
- D. It prints: John 30
Answer: D
NEW QUESTION # 54
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main(){
int *i;
i = new int;
*i = 1.0 / 2 * 2 / 1 * 2 / 4 * 4;
cout << *i;
return 0;
}
- A. It prints: 0.5
- B. It prints: 1
- C. It prints: 0
- D. It prints: 2
Answer: D
NEW QUESTION # 55
Which code, inserted at line 15, generates the output "5 Bob"?
#include <iostream>
#include <string>
using namespace std;
class B;
class A {
int age;
public:
A () { age=5; };
friend void Print(A &ob, B &so);
};
class B {
string name;
public:
B () { name="Bob"; };
//insert code here
};
void Print(A &ob, B &so) {
cout<<ob.age << " " << so.name;
}
int main () {
A a;
B b;
Print(a,b);
return 0;
}
- A. friend void Print(A *ob, B *so);
- B. None of these
- C. friend void Print(A ob, B so);
- D. friend void Print(A &ob, B &so);
Answer: D
NEW QUESTION # 56
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];
A *bc = (A*)sc;
for (int i=0; i<2;i++)
(bc++)->print();
return 0;
}
- A. It prints: B A
- B. It prints: A A
- C. It prints: B B
- D. It prints: A B
Answer: B
NEW QUESTION # 57
What will the variable "y" be in class B?
class A {
int x;
protected:
int y;
public:
int age;
};
class B : private A {
string name;
public:
void Print() {
cout << name << age;
}
};
- A. protected
- B. None of these
- C. private
- D. public
Answer: C
NEW QUESTION # 58
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main()
{
int x=2, *y;
y = &x;
cout << *y + x;
return 0;
}
- A. It prints: 1
- B. It prints: 0
- C. It prints: 2
- D. It prints: 4
Answer: D
NEW QUESTION # 59
What is the output of the program given below?
#include <iostream>
using namespace std;
int main (int argc, const char * argv[])
{
float f=?10.501;
cout<<(int)f;
}
- A. 0
- B. ?10
- C. ?11
- D. 1
Answer: B
NEW QUESTION # 60
What is the expected result of the following program?
- A. It prints: ACBD
- B. It prints: ACDB
- C. It prints: ABCD
- D. It prints: CABD
Answer: A
NEW QUESTION # 61
......
CPA-21-02 Dumps are Available for Instant Access: https://www.exam4tests.com/CPA-21-02-valid-braindumps.html
Practice with these CPA-21-02 dumps Certification Sample Questions: https://drive.google.com/open?id=1IjE_hhxY_qplL3z0RC7GQ2Mt2Mnu-vdg