[2024] Easy To Download CPA-21-02 Actual Exam Dumps Resources [Q98-Q120]

Share

[2024] Easy To Download CPA-21-02 Actual Exam Dumps Resources

Uplift Your CPA-21-02 Exam Marks With The Help of CPA-21-02 Dumps

NEW QUESTION # 98
What happens when you attempt to compile and run the following code?

  • A. It prints: 5.2110.0
  • B. It prints: 5210
  • C. It prints: 52.10
  • D. It prints: 5.210.0

Answer: C


NEW QUESTION # 99
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <exception>
using namespace std;
class myClass : public exception
{
virtual const char* what() const throw()
{
return "My exception.";
}
} obj;
int main () {
try
{
throw obj;
}
catch (exception& e)
{
cout << e.what() << endl;
}
return 0;
}

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

Answer: D


NEW QUESTION # 100
Which code, inserted at line 12, generates the output "5b"?
#include <iostream>
using namespace std;
namespace myNamespace1
{
int var = 5;
}
namespace myNamespace2
{
char var = 'b';
}
int main () {
//insert code here
return 0;
}

  • A. cout << myNamespace1::var << myNamespace2::var;
  • B. cout << var << var;
  • C. cout << myNamespace1::var << var;
  • D. None of these

Answer: A


NEW QUESTION # 101
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int op(int x, int y);
int main()
{
int i=2, j=2, k;
float f=0.3;
k = op(i, j);
cout<< k << "," << op(1, f);
return 0;
}
int op(int x, int y)
{
return x+y;
}

  • A. It prints: 4,1
  • B. It prints: 4,0
  • C. It prints: 4,0.7
  • D. It prints: 0,4

Answer: A


NEW QUESTION # 102
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
int f(int i);
int main()
{
int i=0;
i++;
for (i=0; i<=2; i++)
{
cout<<f(i);
}
return 0;
}
int f(int a)
{
return a+a;
}

  • A. It prints: 202020
  • B. It prints: 024
  • C. It prints: 0
  • D. It prints: 012

Answer: B


NEW QUESTION # 103
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
class A {
public:
A() { cout << "A no parameters";}
A(string s) { cout << "A string parameter";}
A(A &a) { cout << "A object A parameter";}
};
class B : public A {
public:
B() { cout << "B no parameters";}
B(string s) { cout << "B string parameter";}
B(int s) { cout << "B int parameter";}
};
int main () {
A a2("Test");
B b1(10);
B b2(b1);
return 0;
}

  • A. It prints: A no parametersA no parametersB string parameter
  • B. It prints: A no parametersA no parameters
  • C. It prints: A no parametersB string parameter
  • D. It prints: A string parameterA no parametersB int parameterA object A parameter

Answer: D


NEW QUESTION # 104
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 A {
public:
virtual void Print(){ cout<< "B"; }
};
class C:public B {
public:
void Print(){ cout<< "C"; }
};
int main()
{
A ob1;
B ob2;
C ob3;
A *obj;
obj = &ob1;
obj?>Print();
obj = &ob2;
obj?>Print();
obj = &ob3;
obj?>Print();
}

  • A. It prints: ABC
  • B. It prints: BBB
  • C. It prints: AAA
  • D. It prints: ABB

Answer: C


NEW QUESTION # 105
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: 00
  • B. It prints: 10
  • C. It prints: 2020
  • D. It prints: 22

Answer: C


NEW QUESTION # 106
What is the output of the program if character 4 is supplied as input?
#include <iostream>
using namespace std;
int main () {
int c;
cin >> c;
try
{
switch (c)
{
case 1:
throw 20;
case 2:
throw 5.2f;
case 3:
throw 'a';
default:
cout<<"No exception";
}
}
catch (int e)
{ cout << "int exception. Exception Nr. " << e; }
catch (float e)
{ cout << "float exception. Exception Nr. " << e; }
catch (...)
{ cout << "An exception occurred."; }
return 0;
}

  • A. It prints: float exception. Exception Nr.
  • B. It prints: int exception. Exception Nr.
  • C. It prints: No exception
  • D. It prints: An exception occurred

Answer: C


NEW QUESTION # 107
How many times will "HELLO" be printed?
#include <iostream>
using namespace std;
int main()
{
for(int i=?1; i<=10; i++)
{
if(i < 5)
continue;
else
break;
cout<<"HELLO";
}
return 0;
}

  • A. 0
  • B. 1
  • C. 2
  • D. 3

Answer: A


NEW QUESTION # 108
What is the output of the program?
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s1[]= {"H" , "t" };
string s;
for (int i=0; i<2; i++) {
s = s1[i];
s.insert(1,"ow");
cout << s;
}
return( 0 );
}

  • A. It prints: Howtow
  • B. It prints: Ht
  • C. It prints: Hoto
  • D. It prints: How

Answer: A


NEW QUESTION # 109
What is the output of the program?
#include <iostream>
using namespace std;
class BaseC
{
int i;
public:
BaseC() { i=?1;}
BaseC(int i) { i=i; }
void seti(int a) { i = a; };
void Print() { cout << i; }
};
int main()
{
BaseC *o = new BaseC();
o?>seti(10);
o?>Print();
}

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

Answer: C


NEW QUESTION # 110
Which of the following operations is INCORRECT?

  • A. double d=12;
  • B. int i=15;
  • C. float f=12,2;
  • D. long int k=123

Answer: C


NEW QUESTION # 111
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
class B;
class A {
int age;
public:
A () { age=5; };
friend class B;
};
class B {
string name;
public:
B () { name="Bob"; };
void Print(A ob) {
cout << name << ob.age;
}
};
int main () {
A a;
B b;
b.Print(a);
return 0;
}

  • A. It prints: Bob
  • B. It prints: Bob5
  • C. None of these
  • D. It prints: 5

Answer: B


NEW QUESTION # 112
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);
}

  • A. It prints: 20
  • B. It prints: 10
  • C. It prints: 2010
  • D. It prints: 1020

Answer: A


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;
int z;
A() { x=2; y=2; z=3; }
A(int a, int b) : x(a), y(b) { z = x ? y;}
void Print() {
cout << z;
}
};
int main () {
A a(2,5);
a.Print();
return 0;
}

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

Answer: B


NEW QUESTION # 114
What happens when you attempt to compile and run the following code?

  • A. It prints: 13
  • B. It prints: 12
  • C. It prints: l
  • D. It prints: 2

Answer: D


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

  • A. It prints: 01245
  • B. It prints: 0
  • C. It prints: 05
  • D. It prints: 012345

Answer: A


NEW QUESTION # 116
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
class First
{
public:
First() { cout << "Constructor";}
void Print(){ cout<<"from First";}
};
int main()
{
First FirstObject;
FirstObject.Print();
}

  • A. It prints: Constructor
  • B. None of these
  • C. It prints: from First
  • D. It prints: Constructorfrom First

Answer: D


NEW QUESTION # 117
If there is one, point out an error in the program
#include <iostream>
using namespace std;
int main()
{
int i=1;
for(;;)
{
cout<<i++;
if(i>5)
break;
}
return 0;
}

  • A. No error
  • B. Error in "for" loop
  • C. Error in "if" statement
  • D. Error in break statement

Answer: A


NEW QUESTION # 118
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
void fun(int &i);
int main()
{
int i=2;
fun(i);
cout<<i;
return 0;
}
void fun(int &i)
{
i+=2;
}

  • A. It prints: 0
  • B. It prints: 16
  • C. It prints: 2
  • D. It prints: 4

Answer: D


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

  • A. It prints: 111
  • B. It prints: 1
  • C. It prints: 121
  • D. It prints: 2

Answer: C


NEW QUESTION # 120
......

Use C++ Institute CPA-21-02 Dumps To Succeed Instantly in CPA-21-02 Exam: https://actualtests.passsureexam.com/CPA-21-02-pass4sure-exam-dumps.html