Download CPA - C++ Certified Associate Programmer.CPA-21-02.VCEplus.2023-12-22.64q.vcex

Vendor: C++ Institute
Exam Code: CPA-21-02
Exam Name: CPA - C++ Certified Associate Programmer
Date: Dec 22, 2023
File Size: 355 KB
Downloads: 1

How to open VCEX files?

Files with VCEX extension can be opened by ProfExam Simulator.

Purchase
Coupon: EXAM_HUB

Discount: 20%

Demo Questions

Question 1
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main()
{ int i
=
0;
i++;
goto lab;
i++;
lab:
cout<<i;
return 0;
}
  1. It prints: 0
  2. It prints: 34
  3. It prints: 1
  4. It prints: 3
Correct answer: C
Question 2
What is the output of the program?
#include <iostream>
#include <string>
using namespace std;
int main()
{
char str[] = 'Hello\0\World\0';
cout << str;
return 0;
}
  1. It prints: Hello
  2. It prints: World
  3. It prints: HW
  4. It prints: World\0World
Correct answer: A
Question 3
If there is one, point out an error in the program
#include <iostream>
using namespace std;
int main()
{ int c = 'a';
switch(i)
{
case '2':
cout<<'OK';
case '1':
cout<<'Error';
default:
break;
}
return 0;
}
  1. No Error
  2. Use of undeclared identifier 'i'
  3. Illegal use of 'continue'
  4. Illegal use of 'break'
Correct answer: B
Question 4
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
class A {
int x;
protected:
int y;
public:
int z;
A() { x=1; y=2; z=3; }
};
class B : public A {
string z;
public:
void set() { y = 4; z = 'John'; }
void Print() { cout << y << A::z; }
};
int main () {
B b;
b.set();
b.Print();
return 0;
}
  1. It prints: 4John
  2. It prints: 2John
  3. It prints: 23
  4. It prints: 43
Correct answer: D
Question 5
Which code, inserted at line 10, generate the output '50'?
#include <iostream>
using namespace std;
class Base {
int age;
public:
Base () {
age=5;
};
//insert code here
void Print() { cout << age;}
};
void setAge(Base &ob) {ob.age = 0;}
int main () {
Base a;
a.Print();
setAge(a);
a.Print();
return 0;
}
  1. friend void setAge(Base ob);
  2. friend void setAge(Base *ob);
  3. friend void setAge(Base &ob);
  4. None of these
Correct answer: C
Question 6
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
class First
{
public:
First() { cout << 'Constructor';}
void Print(){ cout<<'from First';}
};
int main()
{
First FirstObject;
FirstObject.Print();
}
  1. It prints: Constructorfrom First
  2. It prints: Constructor
  3. It prints: from First
  4. None of these
Correct answer: A
Question 7
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
void fun(int i);
int main()
{ int i=0;
i++;
for (i=0; i<=5; i++)
{ fun(i);
}
return 0;
}
void fun(int i)
{ if (
i==3)
return;
cout << i;
}
  1. It prints: 05
  2. It prints: 012345
  3. It prints: 01245
  4. It prints: 0
Correct answer: C
Question 8
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main()
{ int i = 5;
do {
i??;
cout<<i;
}
while(i >= 0);
return 0;
}
  1. It prints: 43210?1
  2. It prints: ?1
  3. It prints: 4321
  4. It prints: 1
Correct answer: A
Question 9
What will happen when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
string fun(string, string);
int main()
{
string s='Hello';
cout << fun(s, ' World');
return 0;
}
string fun(string s1, string s2)
{
return s1+s2;
}
  1. It will print: Hello World
  2. It will print: Hello
  3. It will print: World
  4. It will print: HW
Correct answer: A
Question 10
What is not inherited from the base class?
  1. constructor
  2. destructor
  3. operator=()
  4. operator+()
Correct answer: ABC
HOW TO OPEN VCE FILES

Use VCE Exam Simulator to open VCE files
Avanaset

HOW TO OPEN VCEX AND EXAM FILES

Use ProfExam Simulator to open VCEX and EXAM files
ProfExam Screen

ProfExam
ProfExam at a 20% markdown

You have the opportunity to purchase ProfExam at a 20% reduced price

Get Now!