The Best C++ Institute CPA-21-02 Study Guides and Dumps of 2024 [Q142-Q156]

Rate this post

The Best C++ Institute CPA-21-02 Study Guides and Dumps of 2024

Top C++ Institute CPA-21-02 Exam Audio Study Guide! Practice Questions Edition

QUESTION 142
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”;}
};
int main()
{
A *obj;
A ob1;
obj = &ob1;
obj?>Print();
B ob2;
obj = &ob2;
obj?>Print();
}

 
 
 
 

QUESTION 143
Which of the following statements are true? (Choose two.)

 
 
 
 

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

 
 
 
 

QUESTION 145
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=1; 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;
}

 
 
 
 

QUESTION 146
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 147
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(1) || fun(2);
cout << i;
return 0;
}

 
 
 
 

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

 
 
 
 

QUESTION 149
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:”;
}

 
 
 
 

QUESTION 150
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main()
{
int *t;
t = new int[2];
for (int i=0; i<2; i++) {
t[i]=0;
}
cout << t[1];
}

 
 
 
 

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

 
 
 
 

QUESTION 152
Which of the following operators accept integer arguments only? (Choose two.)

 
 
 
 

QUESTION 153
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:
void Print(){ cout<< “B”;}
};
int main()
{
A *obj;
A ob1;
obj = &ob1;
obj?>Print();
B ob2;
obj = &ob2;
obj?>Print();
}

 
 
 
 

QUESTION 154
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main()
{
float x=3.5,y=1.6;
int i,j=2;
i = x + j + y;
cout << i;
return 0;
}

 
 
 
 

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

 
 
 
 

QUESTION 156
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];
if (i==0)
s.insert(1,”ow”);
else
s.push_back(‘o’);
cout << s;
}
return( 0 );
}

 
 
 
 

Valid CPA-21-02 Exam Updates – 2024 Study Guide: https://www.passtestking.com/c-plus-plus-institute/CPA-21-02-practice-exam-dumps.html

admin

Leave a Reply

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

Enter the text from the image below
 

Post comment