CPA Braindumps Real Exam Updated on Mar 14, 2022 with 220 Questions [Q103-Q120]

Share

CPA Braindumps Real Exam Updated on Mar 14, 2022 with 220 Questions

Latest CPA PDF Dumps & Real Tests Free Updated Today

NEW QUESTION 103
What is the output of the program?
#include <iostream>
#include <string>
using namespace std;
struct Person {
int age;
};
class First
{
Person *person;
public:
First() {person = new Person;
person?>age = 20;
}
void Print(){
cout << person?>age;
}
};
int main()
{
First t[2];
for (int i=0; i<2; i++)
t[i].Print();
}

  • A. It prints: 22
  • B. It prints: 00
  • C. It prints: 10
  • D. It prints: 2020

Answer: D

Explanation:
Section: Volume A

 

NEW QUESTION 104
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
class A {
public:
string s;
A(string s) { this>s = s; }
};
class B {
public:
string s;
B (A a) { this>s = a.s; }
void print() { cout<<s; }
};
int main()
{
A a("Hello world");
B b=a;
b.print();
}

  • A. Compilation error
  • B. It prints: Hello world
  • C. It prints: Hello
  • D. None of these

Answer: B

Explanation:
Section: Volume A

 

NEW QUESTION 105
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main()
{
int i = 0;
do {
i++;
if (i==3)
break;
cout<<i;
}
while(i < 5);
return 0;
}

  • A. It prints: 0
  • B. It prints: 1
  • C. It prints: 12
  • D. No output

Answer: C

Explanation:
Section: Volume B

 

NEW QUESTION 106
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main()
{
int i=2;
switch(i)
{
case 1:
cout<<"Hello";
break;
case 2:
cout<<"world";
break;
case 3:
printf("End");
break;
}
return 0;
}

  • A. It prints: End
  • B. It prints: Hello
  • C. It prints: world
  • D. It prints: E

Answer: C

 

NEW QUESTION 107
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. Runtime error.
  • B. It prints: ERROR
  • C. Compilation error
  • D. It prints: OK

Answer: D

 

NEW QUESTION 108
What happens when you attempt to compile and run the following code?
#include <iostream> using namespace std;
class A { public: int x; A() { x=0;} };
class B : public A {
public:
B() { x=1;}
};
class C : private B {
public:
C() { x=2;}
};
int main () {
C c1;
cout << c1.x;
return 0;
}

  • A. It prints: 010
  • B. It prints: 110
  • C. Compilation error
  • D. It prints: 210

Answer: C

 

NEW QUESTION 109
Which of the following is a logical operator?

  • A. !
  • B. ||
  • C. &&
  • D. &

Answer: A,B,C

 

NEW QUESTION 110
What happens when you attempt to compile and run the following code?
#include <cstdlib>
#include <iostream>
using namespace std;
float* sum(float a,float b);
float* sum(float a,float b)
{
float *f = new float;
*f = a+b;
return f;
}
int main()
{
float a,b,*f;
a = 1.5; b = 3.4;
f = sum(a,b);
cout<<*f;
return 0;
}

  • A. It prints: 0
  • B. It prints: 5
  • C. It prints: 4.9
  • D. It prints: 4

Answer: C

 

NEW QUESTION 111
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. friend void Print(A *ob, B *so);
  • C. None of these
  • D. friend void Print(A ob, B so);

Answer: A

Explanation:
Section: Volume A

 

NEW QUESTION 112
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <cstdarg>
using namespace std;
int mult(int f, int s, int t);
int main()
{
cout << mult(1,2,3);
return 0;
}
int mult(int f, int s, int t)
{
int mult_res;
mult_res = f*s*t;
return mult_res;
}

  • A. It prints: 0
  • B. It prints: 2
  • C. It prints: 6
  • D. It prints: 3

Answer: C

 

NEW QUESTION 113
What happens when you attempt to compile and run the following code?
#include <iostream> #include <string>
using namespace std;
class A {
protected:
int y;
public:
int x, z;
A() : x(1), y(2), z(0) {}
A(int a, int b) : x(a), y(b) { z = x * y;}
void Print() { cout << z; }
};
class B : public A {
public:
int y;
B() : A() {}
B(int a, int b) : A(a,b) {}
void Print() { cout << z; }
};
int main () {
A b(2,5);
b.Print();
return 0;
}

  • A. It prints: 10
  • B. It prints: 2
  • C. It prints: 1
  • D. It prints: 5

Answer: A

 

NEW QUESTION 114
Which code, inserted at line 10, generate the output "50"?
#include <iostream>
using namespace std;
class Base {
int age;
public:
Base () {
age=5;
};
//insert code here
void Print() { cout << age;}
};
void setAge(Base &ob) {ob.age = 0;}
int main () {
Base a;
a.Print();
setAge(a);
a.Print();
return 0;
}

  • A. friend void setAge(Base &ob);
  • B. friend void setAge(Base ob);
  • C. None of these
  • D. friend void setAge(Base *ob);

Answer: A

 

NEW QUESTION 115
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
#define DEF_A 0
int main(int argc, char *argv[]) {
cout << DEF_A;
return 0;
}

  • A. It prints: 0
  • B. Compilation error
  • C. It prints: ?1
  • D. It prints: 1

Answer: A

 

NEW QUESTION 116
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
class A {
protected:
int y;
public:
int x,z;
A() : x(1), y(2), z(0) { z = x + y; }
A(int a, int b) : x(a), y(b) { z = x + y;}
void Print() { cout << z; }
};
class B : public A {
public:
int y;
B() : A() {}
B(int a, int b) : A(a,b) {}
void Print() { cout << z; }
};
int main () {
A b;
b.Print();
return 0;
}

  • A. It prints: 0
  • B. It prints: 2
  • C. It prints: 1
  • D. It prints: 3

Answer: D

 

NEW QUESTION 117
What is the output of the program?
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s1="Wo";
string s2;
s2 = s1;
string s3;
s3 = s2.append("rldHello");
cout << s3;
return( 0 );
}

  • A. It prints: HelloWo
  • B. It prints: World
  • C. It prints: Hello
  • D. It prints: WorldHello

Answer: D

Explanation:
Section: Volume A

 

NEW QUESTION 118
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: o
  • B. It prints: el
  • C. It prints: Hello
  • D. It prints: H

Answer: C

 

NEW QUESTION 119
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main()
{
const int x=20;
const int *ptr;
ptr = &x;
*ptr = 10;
cout<<*ptr;
return 0;
}

  • A. It prints: 10
  • B. It prints: 20
  • C. It prints address of ptr
  • D. Compilation error at line 8

Answer: D

 

NEW QUESTION 120
......


Conclusion

Given that C++ is simple and efficient, it is considered to be one of the most popular programming languages. So, the CPA exam offered by C++ Institute is great for programmers to test their skills and understanding of concepts that should be applied in their professions. Moreover, it leads to the C++ Certified Associate Programmer certification and helps the applicants to be updated with the needs of their roles.

At the same time, don't forget the preparation, because only with the help of the actual training courses and study guides, you are more inclined to the desired effect.

 

CPA Dumps With 100% Verified Q&As - Pass Guarantee or Full Refund: https://prepaway.testkingpass.com/CPA-testking-dumps.html