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

Page 14 of 65

Which code, inserted at line 8, generates the output "0102020"?

#include <iostream>
using namespace std;
class Base {
static int age;
public:
Base () {};
~Base () {};
//insert code here void Print() { cout << age;}
};

int Base::age=0;

int main () {
Base a,*b;

b = new Base();

  1. Print();
  2. setAge(10);
  3. Print();
    b?>setAge();
  4. Print();
    b?>Print();
    return 0;
    }
  5. void setAge(int a) {age = a;}
  6. void setAge() {age = 20;}

  7. void setAge() {age = 10;}
  8. void setAge(int a=20) {age = a;}

Answer(s): D



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

#include <iostream>

using namespace std;

class First
{
public:
void Print(){ cout<<"from First";}
};
class Second
{
public:
void Print(){ cout<< "from Second";}
};
int main()
{
First FirstObject;
FirstObject.Print();
Second SecondObject;
SecondObject.Print();
}

  1. It prints: from First
  2. It prints: from Firstfrom First
  3. It prints: from Firstfrom Second
  4. It prints: from Secondfrom Second

Answer(s): C



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

#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
char *s = "ABCDEF";
cout << s+2;
return 0;
}

  1. It prints: CDEF
  2. It prints: ABCDEF
  3. It prints: BCDEF
  4. None of these

Answer(s): A



Which of the following can be checked in a switch?case statement?

  1. char
  2. int
  3. enum
  4. double

Answer(s): A,B,C



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