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

Page 5 of 65

What will the variable "age" be in class B?

class A {
int x;
protected:
int y;
public:
int age;
};

class B : private A {
string name;
public:
void Print() {
cout << name << age;
}
};

  1. public
  2. private
  3. protected
  4. None of these

Answer(s): B



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

#include <iostream>

using namespace std;

int x=5;
static int y;
int i=0;

void static myFunction()
{
y=x++ + ++i;
}

int main (int argc, const char * argv[])
{
x++;
myFunction();
cout<<y<<" "<<x<< " " << i;
}

  1. Compilation fails
  2. It prints: 5 5 0
  3. It prints: 7 7 1
  4. It prints: 6 5 1

Answer(s): C



Which of the structures is incorrect?

1:
struct s1{
int x;
long int li;

};

2:
struct s2{
float f;
struct s2 *s;
};

3:
struct s3{
float f;
struct s3 s;
};

  1. 1
  2. 2
  3. 3
  4. 2, 3

Answer(s): C



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

  1. It prints: WorldHello
  2. It prints: HelloWo
  3. It prints: World
  4. It prints: Hello

Answer(s): A



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