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

Page 35 of 65

What is the output of the program?

#include <iostream>
#include <string>

using namespace std;

class First
{
string name;
public:
First() {
name = "Alan";
}
void setName(string n) {this?>name = n;}

void setName() {this?>name = "John";}
void Print(){
cout << name;
}
};

int main()
{
First ob1,*ob2;
ob2 = new First();
First *t;
t = &ob1;

t?>setName();
t?>Print();
t = ob2;
t?>setName("Steve");
ob2?>Print();
}

  1. It prints: JohnSteve
  2. It prints: AlanAlan
  3. It prints: AlanSteve
  4. It prints: JohnAlan

Answer(s): A



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

  1. 0
  2. 11
  3. ?10
  4. ?11

Answer(s): C



What is the output of the program?

#include <iostream>
#include <string>

using namespace std;

int main()

{
string s1[]= {"H" , "t" };
string s;

for (int i=0; i<2; i++) {
s = s1[i];
if (i==0)

  1. insert(1,"ow");
    else
  2. push_back('o');
    cout << s;
    }
    return( 0 );
    }
  3. It prints: Hoto
  4. It prints: Ht
  5. It prints: toHo
  6. It prints: Howto

Answer(s): D



How many times will "HELLO" be printed?

#include <iostream>

using namespace std;

int main()
{
for(int i=?1; i<=10; i++)
{
if(i < 5)

continue;
else break;
cout<<"HELLO";
}
return 0;
}

  1. 1
  2. 2
  3. 0
  4. 20

Answer(s): C



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