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

Page 11 of 65

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

#include <iostream>

using namespace std;

#include <iostream>

using namespace std;

class First
{
public:
void Print(){ cout<<"from First";}
};

int main()
{
First t[2];
for (int i=0; i<2; i++)
t[i].Print();
}

  1. It prints: from First
  2. It prints: from Firstfrom First
  3. Compilation error
  4. Runtime error.

Answer(s): B



What is the output of the program given below?

#include <iostream>

using namespace std;

int main (int argc, const char * argv[])

{
int i=10;
{
int i=0;
cout<<i;
}
cout<<i;
return 0;
}

  1. 1010
  2. 100
  3. 010
  4. None of these

Answer(s): C



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

#include <iostream>
#include <string>
using namespace std;

class A {
public:
int x;
A() { x=0;}
A(int x) { this?>x=x;}
};

class B : private A {

public:
using A::x;
B() { x=1;}
B(int x) {this?>x = x;}
};

int main () {
B c1;
B c2(?5);
cout << c1.x;
cout << c2.x;

return 0;

}

  1. It prints: 5
  2. It prints: 1?5
  3. It prints: 05
  4. It prints: 0

Answer(s): B



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 a = 30, b = 1, c = 5, i=10;
i = b < a < c;
cout << i;
return 0;
}

  1. compilation fails
  2. It prints: 10
  3. It prints: 0
  4. It prints: 1

Answer(s): D



Page 11 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