
Pass C++ Institute CPA PDF Dumps | Recently Updated 220 Questions
Updated Test Engine to Practice CPA Dumps & Practice Exam
NEW QUESTION 87
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
void print(char *c);
int main (int argc, const char * argv[])
{
print("Test");
return 0;
}
void print(char *c)
{
cout<<c;
}
- A. It prints: st
- B. It prints: Test
- C. None of these
- D. It prints: T
Answer: B
NEW QUESTION 88
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 89
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 parameters
- B. It prints: A no parametersB string parameter
- C. It prints: A no parametersA no parametersB string parameter
- D. It prints: A string parameterA no parametersB int parameterA object A parameter
Answer: D
NEW QUESTION 90
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 parameters
- B. It prints: A no parametersB string parameter
- C. It prints: A no parametersA no parametersB string parameter
- D. It prints: A string parameterA no parametersB int parameterA object A parameter
Answer: D
NEW QUESTION 91
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: Bob5
- B. It prints: Bob
- C. It prints: 5
- D. None of these
Answer: A
Explanation:
Section: Volume A
NEW QUESTION 92
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main()
{
int i = 5;
cout<<"Hello World" << ++i;
return 0;
}
- A. It prints: World
- B. It prints: Hello
- C. It prints: Hello World5
- D. It prints: Hello World6
Answer: D
NEW QUESTION 93
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
NEW QUESTION 94
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;
}
- A. It prints: 0
- B. It prints: 6
- C. It prints: 3
- D. It prints: 4
Answer: B
Explanation:
Section: Volume A
NEW QUESTION 95
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main()
{
int i = 4;
while(i >= 0) {
cout<<i;
i;
}
return 0;
}
- A. It prints:"43210"
- B. It prints:"3210"
- C. None of these
- D. It prints: "3210?1"
Answer: A
NEW QUESTION 96
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.3) {}
complex(double n) { re=n,im=n;};
complex(int m,int n) { re=m,im=n;}
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(1),c2(2),c3;
c3 = c1 + c2;
c3.Print();
}
- A. It prints: 0 0
- B. It prints: 3 3
- C. It prints: 1 1.5
- D. It prints: 2 1.5
Answer: B
NEW QUESTION 97
What will the variable "age" 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;
}
};
- A. public
- B. private
- C. None of these
- D. protected
Answer: D
Explanation:
Section: Volume A
Explanation/Reference:
NEW QUESTION 98
What is the output of the program?
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s1[]= {"Hello" , "World" };
for (int i=0; i<2; i++) {
cout << s1[i];
}
return( 0 );
}
- A. It prints: WorldHello
- B. It prints: HelloWorld
- C. It prints: World
- D. It prints: Hello
Answer: B
Explanation:
Section: Volume A
Explanation
NEW QUESTION 99
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];
B *bc = (B*)sc;
for (int i=0; i<2;i++)
(bc++)->print();
return 0;
}
- A. It prints: A A
- B. It prints: B A
- C. It prints: A B
- D. It prints: B B
Answer: D
NEW QUESTION 100
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
NEW QUESTION 101
What is the output of the program?
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s1="World";
string s2;
s2="Hello" + s1;
cout << s2;
return( 0 );
}
- A. Compilation error
- B. It prints: HelloWorld
- C. It prints: World
- D. It prints: Hello
Answer: B
NEW QUESTION 102
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 103
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main()
{
int i = 0;
i++;
goto lab;
i++;
lab:
cout<<i;
return 0;
}
- A. It prints: 0
- B. It prints: 34
- C. It prints: 3
- D. It prints: 1
Answer: D
NEW QUESTION 104
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 = 3.0;
c1.print();
return 0;
}
- A. It prints: 0 0
- B. It prints: 3 3
- C. Compilation error
- D. It prints: 1 1
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;
namespace myNamespace1
{
int x = 5;
int y = 10;
}
namespace myNamespace2
{
float x = 3.14;
float y = 1.5;
}
int main () {
{
using namespace myNamespace1;
cout << x << " ";
}{
using namespace myNamespace2;
cout << y;
}
return 0;
}
- A. It prints: 5 1.5
- B. Compilation error
- C. None of these
- D. It prints: 3.14 10
Answer: A
NEW QUESTION 106
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
class A {
int x;
protected:
int y;
public:
int z;
A() { x=1; y=2; z=3; }
};
class B : public A {
string z;
public:
void set() {
y = 4;
z = "John";
}
void Print() {
cout << y << z;
}
};
int main () {
B b;
b.set();
b.Print();
return 0;
}
- A. It prints: 43
- B. It prints: 4John
- C. It prints: 2John
- D. It prints: 23
Answer: B
Explanation:
Section: Volume A
NEW QUESTION 107
Which of the following statements are correct?
- A. In a function two return statements should never occur.
- B. A function can be defined inside another function
- C. A function can return floating point value
- D. A function may have any number of return statements each returning different values.
Answer: C,D
Explanation:
Section: Volume A
NEW QUESTION 108
What is the output of the program?
#include <iostream>
#include <string>
using namespace std;
int main () {
string s1 = "Hello", s2 = "World";
s2 = s1 + s2;
cout << s2;
return 0;
}
- A. It prints: WorldHelloWorld
- B. It prints: WorldHello
- C. It prints: HelloWorld
- D. It prints: Hello
Answer: C
Explanation:
Section: Volume A
NEW QUESTION 109
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 110
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int compare(int, int);
int main()
{
int x = compare(10, 20);
cout << x;
return 0;
}
int compare(int i, int j)
{
return i<j;
}
- A. It prints: 0
- B. It prints: 2
- C. It prints: 10
- D. It prints: 1
Answer: D
Explanation:
Section: Volume B
NEW QUESTION 111
......
C++ Institute CPA Dumps Cover Real Exam Questions: https://www.updatedumps.com/c-plus-plus-institute/CPA-updated-exam-dumps.html
Dumps Collection CPA Test Engine Dumps Training With 220 Questions: https://drive.google.com/open?id=1_RGJskwh9_h-xINrxRtHQF4GksaL6WaC