September 27, 2024

Quality CPA-21-02 PDF Dumps – CPA-21-02 Exam Questions [Q97-Q115]

Rate this post

Quality CPA-21-02 PDF Dumps – CPA-21-02 Exam Questions

Most UptoDate C++ Institute CPA-21-02 Exam Dumps PDF 2024

QUESTION 97
What is the meaning of the following declaration? (Choose two.)
char **ptr;

 
 
 
 

QUESTION 98
Given:
#include <iostream>
#include <exception>
using namespace std;
int main () {
try
{
int * myarray= new int[1000];
}
catch (bad_alloc&)
{
cout << “Error allocating memory”;
}
catch (exception& e)
{
cout << “Standard exception”;
}
catch (…)
{
cout << “Unknown exception”;
}
return 0;
}
What will happen if we use the operator “new” and the memory cannot be allocated?

 
 
 
 

QUESTION 99
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;
}

 
 
 
 

QUESTION 100
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
class complex{
double re;
double im;
public:
complex() : re(0),im(0) {}
complex(double x) { re=x,im=x;};
complex(double x,double y) { re=x,im=y;}
void print() { cout << re << ” ” << im;}
};
int main(){
complex c1;
c1.print();
return 0;
}

 
 
 
 

QUESTION 101
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
class complex{
double re, im;
public:
complex() : re(1),im(0.4) {}
complex operator?(complex &t);
void Print() { cout << re << ” ” << im; }
};
complex complex::operator? (complex &t){
complex temp;
temp.re = this?>re ? t.re;
temp.im = this?>im ? t.im;
return temp;
}
int main(){
complex c1,c2,c3;
c3 = c1 ? c2;
c3.Print();
}

 
 
 
 

QUESTION 102
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int s(int n);
int main()
{
int a;
a = 3;
cout << s(a);
return 0;
}
int s(int n)
{
if(n == 0) return 1;
return s(n?1)*n;
}

 
 
 
 

QUESTION 103
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int f(int a, int b);
int main()
{
float b;
b = f(20,10);
cout << b;
return 0;
}
int f(int a, int b)
{
return a/b;
}

 
 
 
 

QUESTION 104
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;
}

 
 
 
 

QUESTION 105
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
void set(struct person*);
struct person
{
char name[25];
int age;
};
int main()
{
struct person e = {“Steve”, 30};
set(&e);
cout<< e.name << ” ” << e.age;
return 0;
}
void set(struct person *p)
{
p?>age = p?>age + 1;
}

 
 
 
 

QUESTION 106
What is the output of the program?
#include <iostream>
#include <string>
using namespace std;
struct t
{
int tab[2];
};
class First
{
struct t u;
public:
First() {
u.tab[0] = 1;
u.tab[1] = 0;
}
void Print(){
cout << u.tab[0] << ” ” << u.tab[1];
}
};
int main()
{
First t;
t.Print();
}

 
 
 
 

QUESTION 107
What happens when you attempt to compile and run the following code?

 
 
 
 

QUESTION 108
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
class First
{
string *s;
public:
First() { s = new string(“Text”);}
~First() { delete s;}
void Print(){ cout<<*s;}
};
int main()
{
First FirstObject;
FirstObject.Print();
FirstObject.~First();
}

 
 
 
 

QUESTION 109
Which of the following is a correct way to define the function fun() in the program below?
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main()
{
int a[2][2];
fun(a);
return 0;
}

 
 
 
 

QUESTION 110
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
void fun(char*);
int main()
{
char t[4]={‘0’, ‘1’, ‘2’, ‘3’};
fun(&t[2]);
return 0;
}
void fun(char *a)
{
cout << *a;
}

 
 
 
 

QUESTION 111
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(2), y(2), z(1) { 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;
}

 
 
 
 

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

 
 
 
 

QUESTION 113
Which code, inserted at line 10, generates the output “2?1”?
#include <iostream>
#include <string>
using namespace std;
class A {
protected:
int y;
public:
int z;
};
//insert code here
public:
void set() {
y = 2;
z = 3;
}
void Print() { cout << y << z; }
};
int main () {
B b;
b.set();
b.z = ?1;
b.Print();
return 0;
}

 
 
 
 

QUESTION 114
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int fun(int x);
int main() {
cout << fun(0);
return 0;
}
int fun(int x) {
if(x > 0)
return fun(x-1);
else
return 100;
}

 
 
 
 

QUESTION 115
What will the variable “y” be in class B?
class A {
int x;
protected:
int y;
public:
int age;
};
class B : protected A {
string name;
public:
void Print() {
cout << name << age;
}
};

 
 
 
 

100% Free C++ Certified Professional Programmer CPA-21-02 Dumps PDF Demo Cert Guide Cover: https://www.prepawaypdf.com/c-plus-plus-institute/CPA-21-02-practice-exam-dumps.html

Leave a Reply

Your email address will not be published. Required fields are marked *

Enter the text from the image below