Free CPA-21-02 Exam Braindumps (page: 33)

Page 33 of 65

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;

  1. Print();
    setAge(a);
  2. Print();
    return 0;
    }
  3. friend void setAge(Base ob);
  4. friend void setAge(Base *ob);
  5. friend void setAge(Base &ob);
  6. None of these

Answer(s): C



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();
}

  1. It prints: Constructorfrom First
  2. It prints: Constructor
  3. It prints: from First
  4. None of these

Answer(s): A



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

  1. It prints: 05
  2. It prints: 012345
  3. It prints: 01245
  4. It prints: 0

Answer(s): C



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

#include <iostream>

using namespace std;

int main()
{
int i = 5;
do {
i??;
cout<<i;

}
while(i >= 0);
return 0;
}

  1. It prints: 43210?1
  2. It prints: ?1
  3. It prints: 4321
  4. It prints: 1

Answer(s): A



Page 33 of 65



Post your Comments and Discuss C++ Institute CPA-21-02 exam with other Community members:

Subash commented on October 21, 2024
I am planning to take this exam. Are these 257 questions enough to clear it? Also, does each section have a passing percentage, or is it based on the overall ?
INDIA
upvote