
最適なCPA-21-02試験準備問題集でC++ Institute CPA-21-02問題集PDFを試そう![2024]
C++ Institute CPA-21-02試験受験生を確実にパスさせるCPA-21-02学習問題集
質問 # 30
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
#define FUN(arg) if(arg) cout<<"Test";
int main()
{
int i=1;
FUN(i<3);
return 0;
}
- A. It prints: T
- B. It prints: 0
- C. It prints: T0
- D. It prints: Test
正解:D
質問 # 31
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main()
{
int i = 0;
do {
i++;
if (i==3)
break;
cout<<i;
}
while(i < 5);
return 0;
}
- A. No output
- B. It prints: 12
- C. It prints: 0
- D. It prints: 1
正解:B
質問 # 32
Which code, inserted at line 14, generates the output "3.14 10"?
#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 () {
//insert code here
cout << x << " " << y;
return 0;
}
- A. using namespace myNamespace1;
- B. using namespace myNamespace1; using namespace myNamespace2;
- C. using myNamespace2::y; using myNamespace1::x;
- D. using myNamespace1::y; using myNamespace2::x;
正解:D
質問 # 33
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
class B;
class A {
int age;
public:
A () { age=5; };
friend class B;
};
class B {
string name;
public:
B () { name="Bob"; };
void Print(A ob) {
cout << name << ob.age;
}
};
int main () {
A a;
B b;
b.Print(a);
return 0;
}
- A. It prints: 5
- B. It prints: Bob5
- C. None of these
- D. It prints: Bob
正解:B
質問 # 34
What is the output of the program if characters 'h', 'e', 'l', 'l' , 'o' and enter are supplied as input?
#include <iostream>
#include <string>
using namespace std;
void f();
int main()
{
f();
return 0;
}
void f()
{
char c;
c = cin.get();
cout << c;
if(c != '\n')
f();
}
- A. It prints: o
- B. It prints: olleh
- C. It prints: hello
- D. It prints: h
正解:C
質問 # 35
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
class A {
public:
A() { cout << "A no parameters";}
A(string s) { cout << "A string parameter";}
A(A &a) { cout << "A object A parameter";}
};
class B : public A {
public:
B() { cout << "B no parameters";}
B(string s) { cout << "B string parameter";}
};
int main () {
A a2("Test");
B b1("Alan");
B b2(b1);
return 0;
}
- A. It prints: A no parametersA no parameters
- B. It prints: A string parameterA no parametersB string parameterA object A parameter
- C. It prints: A no parametersB string parameter
- D. It prints: A no parametersA no parametersB string parameter
正解:B
質問 # 36
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 {
public:
void set() {
y = 4; z = 2;
}
void Print() {
cout << y << z;
}
};
int main () {
B b;
b.set();
b.Print();
return 0;
}
- A. It prints: 44
- B. It prints: 2
- C. It prints: 22
- D. It prints: 42
正解:D
質問 # 37
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
int f(int i, int b);
int main()
{
int i=0;
i++;
for (i=0; i<=2; i++)
{
cout<<f(0,i);
}
return 0;
}
int f(int a, int b)
{
return a+b;
}
- A. It prints: 012
- B. It prints: 0
- C. It prints: 2
- D. It prints: 202020
正解:A
質問 # 38
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
class A {
protected:
int y;
public:
int x;
int z;
A() { x=1; y=2; z=3; }
A(int a, int b) : x(a), y(b) { z = x * y;}
void Print() {
cout << z;
}
};
int main () {
A a(2,5);
a.Print();
return 0;
}
- A. It prints: 10
- B. It prints: 6
- C. It prints: 5
- D. It prints: 2
正解:A
質問 # 39
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
class A
{
public:
void Print(){ cout<<"A";}
};
class B:public A
{
public:
virtual void Print(){ cout<< "B";}
};
int main()
{
A *obj;
A ob1;
obj = &ob1;
obj?>Print();
B ob2;
obj = &ob2;
obj?>Print();
}
- A. It prints: AB
- B. It prints: BB
- C. It prints: AA
- D. It prints: BA
正解:C
質問 # 40
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
class A {
protected:
int y;
public:
int x,z;
A() : x(1), y(2), z(0) { z = x + y; }
A(int a, int b) : x(a), y(b) { z = x + y;}
void Print() { cout << z; }
};
class B : public A {
public:
int y;
B() : A() {}
B(int a, int b) : A(a,b) {}
void Print() { cout << z; }
};
int main () {
A b;
b.Print();
return 0;
}
- A. It prints: 0
- B. It prints: 2
- C. It prints: 3
- D. It prints: 1
正解:C
質問 # 41
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();
}
- A. It prints: from Secondfrom Second
- B. It prints: from First
- C. It prints: from Firstfrom First
- D. It prints: from Firstfrom Second
正解:D
質問 # 42
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
class complex{
double re, im;
public:
complex() : re(1),im(0.4) {}
complex operator?(complex &t);
void Print() { cout << re << " " << im; }
};
complex complex::operator? (complex &t){
complex temp;
temp.re = this?>re ? t.re;
temp.im = this?>im ? t.im;
return temp;
}
int main(){
complex c1,c2,c3;
c3 = c1 ? c2;
c3.Print();
}
- A. It prints: 1 0.4
- B. It prints: 1 0.8
- C. It prints: 0 0
- D. It prints: 2 0.8
正解:C
質問 # 43
What is the output of the program?
#include <iostream>
using namespace std;
int main()
{
int tab[4]={10,20,30,40};
tab[1]=10;
int *p;
p=&tab[0];
cout<<*p;
return 0;
}
- A. It prints: 10
- B. It prints: 30
- C. It prints: 11
- D. It prints: 20
正解:A
質問 # 44
Which of the following operators accept integer arguments only? (Choose two.)
- A. ~
- B. | |
- C. |
- D. !
正解:A、C
質問 # 45
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main()
{
float x=3.5,y=1.6;
int i,j=2;
i = x + j + y;
cout << i;
return 0;
}
- A. It prints: 6
- B. Compilation error
- C. It prints: 7,1
- D. It prints: 7
正解:D
質問 # 46
......
的確で最適なアンサー模擬試験はここにある:https://jp.fast2test.com/CPA-21-02-premium-file.html