Get Prepared for Your CPA-21-02 Exam With Actual C++ Institute Study Guide! Pass Your Next CPA-21-02 Certification Exam Easily Hassle Free NEW QUESTION # 108 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] = i;}cout t[1];} A. It prints: 10 B. It prints: 1 C. It prints: ?1 D. It prints: [...]

[Q108-Q125] Get Prepared for Your CPA-21-02 Exam With Actual C++ Institute Study Guide!

Share

Get Prepared for Your CPA-21-02 Exam With Actual C++ Institute Study Guide!

Pass Your Next CPA-21-02 Certification Exam Easily & Hassle Free

NEW QUESTION # 108
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] = i;
}
cout << t[1];
}

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

Answer: B


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

  • A. It prints: from Secondfrom Second
  • B. It prints: from First
  • C. It prints: from Firstfrom First
  • D. It prints: from Firstfrom Second

Answer: C


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

  • A. void fun(int p[][2]) {}
  • B. void fun(int *p[2]) {}
  • C. void fun(int *p[][2]) {}
  • D. void fun(int *p[2][2]) {}

Answer: A


NEW QUESTION # 111
What is the output of the program?
#include <iostream>
using namespace std;
int main()
{
int tab[4]={10,20,30,40};
tab[1]=10;
int *p;
p=&tab[0];
cout<<*p;
return 0;
}

  • A. It prints: 20
  • B. It prints: 10
  • C. It prints: 11
  • D. It prints: 30

Answer: B


NEW QUESTION # 112
Which line of code inserted instead of the comment will make the following code run properly without causing memory leaks?

  • A. no additional code is needed
  • B. ~Base() { delete ptr; delete ptr; }
  • C. ~Base() { delete ptr; }
  • D. ~Base() ( delete this; }

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: 5
  • D. It prints: 1

Answer: A


NEW QUESTION # 114
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main()
{
int *a= new int;
*a=100;
cout << *a;
delete a;
}

  • A. It prints: 100
  • B. It prints: 10
  • C. It prints: 1
  • D. It prints: 0

Answer: A


NEW QUESTION # 115
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;
};
class B : private A {
string name;
public:
void set() {
x = 1;
}
void Print() {
cout << x;
}
};
int main () {
B b;
b.set();
b.Print();
return 0;
}

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

Answer: B


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

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

Answer: D


NEW QUESTION # 117
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
class Base {
static int age;
public:
Base () {};
~Base () {};
void setAge(int a=20) {age = a;}
void Print() { cout << age;}
};
int Base::age=0;
int main () {
Base a;
a.setAge(10);
a.Print();
a.setAge();
a.Print();
return 0;
}

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

Answer: B


NEW QUESTION # 118
What is the output of the program given below?
#include <iostream>
using namespace std;
int main (int argc, const char * argv[])
{
float f=?10.501;
cout<<(int)f;
}

  • A. 0
  • B. 1
  • C. ?10
  • D. ?11

Answer: C


NEW QUESTION # 119
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main (int argc, const char * argv[])
{
int tab[5]={1,2,3};
for (int i=0; i<5; i++)
cout <<tab[i];
return 0;
}

  • A. It prints: 12300
  • B. compilation fails
  • C. It prints: 12345
  • D. It prints: 00000

Answer: A


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

  • A. It prints: 100
  • B. It prints: 10
  • C. It prints: -1
  • D. It prints: 0

Answer: A


NEW QUESTION # 121
Which of the following statements are correct?

  • A. A function may have any number of return statements each returning different values.
  • B. In a function two return statements should never occur.
  • An internal server error occurred.

    Ace CPA-21-02 Certification with 256 Actual Questions: https://freetorrent.braindumpsvce.com/CPA-21-02_exam-dumps-torrent.html