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

Page 27 of 65

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

  1. It prints: 5 1.5
  2. It prints: 3.14 10
  3. Compilation error
  4. None of these

Answer(s): A



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

#include <iostream>
using namespace std;

int main() {
float i = 1.0 / 2 * 2 / 1 * 2 / 4 * 4 / 2;
cout << i;
return 0;
}

  1. It prints: 0
  2. It prints: 1
  3. It prints: 2
  4. It prints: 0.5

Answer(s): B



What is the output of the program?

#include <iostream>
#include <string>

using namespace std;

class First
{
string name;
public:

First() {
name = "Alan";
}
void Print(){
cout << name;
}
};

int main()
{
First ob1,*ob2;
ob2 = new First();
ob1.Print();
ob2?>Print();
}

  1. Garbage value
  2. It prints: AlanAlan
  3. It prints: Alan
  4. It prints: Al

Answer(s): B



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

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

Answer(s): C



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