最上級のCPA-21-02試験問題C++ Instituteテスト最高成績で最速合格をゲットせよ!
試験準備には最適なCPA-21-02試験問題2024年最新のC++ Certified Professional Programmer究極な256問があります
質問 # 59
The following declaration:
int i = 0b10;
- A. sets variable i with an integer value equal to 2 (10 binary)
- B. is invalid
- C. sets variable i with an integer value equal to 10
- D. sets variable i with an integer value equal to 8 (10 octal)
正解:D
質問 # 60
What happens when you attempt to compile and run the following code?
- A. It prints: 121
- B. It prints: 1
- C. lt prints: 2
- D. It prints: 111
正解:A
質問 # 61
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;
}
- A. Use of undeclared identifier 'i'
- B. No Error
- C. Illegal use of 'break'
- D. Illegal use of 'continue'
正解:A
質問 # 62
What is the output of the program?
#include <iostream>
using namespace std;
#define SQR(x)(x*x)
int main(int argc, char *argv[]) {
int x, y=2;
x = SQR(y);
cout << x << ", " <<y;
return 0;
}
- A. It prints: 4, 2
- B. It prints: 3, 3
- C. It prints: 9, 2
- D. It prints: 3, 2
正解:A
質問 # 63
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;
}
- A. It prints: 0
- B. It prints: 0.5
- C. It prints: 1
- D. It prints: 2
正解:C
質問 # 64
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main(void)
{
string s;
s = "Test";
s.resize (s.size() ? 1);
cout<<s<<" "<<s.size();
return 0;
}
- A. It prints: Tes 3
- B. Compilation error
- C. It prints: Test 4
- D. It prints: Test 3
正解:A
質問 # 65
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 :
void print() {
cout << "B ";
}
};
int main() {
B sc[2];
B *bc = (B*)sc;
for (int i=0; i<2;i++)
(bc++)->print();
return 0;
}
- A. It prints: B A
- B. It prints: A B
- C. It prints: A A
- D. It prints: B B
正解:D
質問 # 66
Which of the following can be checked in a switch?case statement?
- A. int
- B. enum
- C. char
- D. double
正解:A、B、C
質問 # 67
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
class Second;
class Base {
int age;
public:
Base () { age=5; };
friend void set(Base &ob, Second &so);
void Print() { cout << age;}
};
class Second {
string name;
public:
friend void set(Base &ob, Second &so);
void Print() { cout << name;}
};
void set(Base &ob, Second &so) {
ob.age = 0; so.name = "Bill";
}
int main () {
Base a;
Second b;
set(a,b);
a.Print();
b.Print();
return 0;
}
- A. It prints: Bill0
- B. Compilation error
- C. None of these
- D. It prints: 0Bill
正解:D
質問 # 68
Which code line inserted instead of the comment below will cause the program to produce the expected output?
- A. using namespace myNamespace1::y; using myNamespace2::x;
- B. using namespace myNamespace2::y; using myNamespace1::x;
- C. using namespace myNamespace1; using namespace myNamespace2;
- D. using namespace myNamespace1;
正解:A
質問 # 69
What will the variable "age" be in class B?
class A {
int x;
protected:
int y;
public:
int age;
};
class B : private A {
string name;
public:
void Print() {
cout << name << age;
}
};
- A. private
- B. None of these
- C. protected
- D. public
正解:A
質問 # 70
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) {}
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(2,5);
b.Print();
return 0;
}
- A. It prints: 1
- B. It prints: 10
- C. It prints: 5
- D. It prints: 2
正解:B
質問 # 71
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int fun(int x);
int main() {
cout << fun(0);
return 0;
}
int fun(int x) {
if(x > 0)
return fun(x-1);
else
return 100;
}
- A. It prints: 0
- B. It prints: 10
- C. It prints: 100
- D. It prints: -1
正解:C
質問 # 72
Which of the following statements may completely ignore their bodies (inner statements)? (Choose three.)
- A. do
- B. for
- C. while
- D. swicch
正解:B、C、D
質問 # 73
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
class BaseClass
{
public:
int *ptr;
BaseClass(int i) { ptr = new int(i); }
~BaseClass() { delete ptr; delete ptr;}
void Print() { cout << *ptr; }
};
void fun(BaseClass x);
int main()
{
BaseClass o(10);
fun(o);
o.Print();
}
void fun(BaseClass x) {
cout << "Hello:";
}
- A. It prints: 10
- B. Runtime error.
- C. It prints: Hello:1
- D. It prints: Hello:
正解:B
質問 # 74
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
const int size = 3;
class A {
public:
string name;
A() { name = "Bob";}
A(string s) { name = s;}
A(A &a) { name = a.name;}
};
class B : public A {
public:
int *tab;
B() { tab = new int[size]; for (int i=0; i<size; i++) tab[i]=1;}
B(string s) : A(s) { tab = new int[size]; for (int i=0; i<size; i++) tab[i]=1;}
~B() { delete tab; }
void Print() {
for (int i=0; i<size; i++) cout << tab[i];
cout << name;
}
};
int main () {
B b1("Alan");
B b2;
b1.tab[0]=0;
b1.Print(); b2.Print();
return 0;
}
- A. It prints: 0
- B. It prints: 011Alan111Bob
- C. It prints: Alan
- D. It prints: 111
正解:B
質問 # 75
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. Compilation error
- B. It prints: 6
- C. It prints: 7,1
- D. It prints: 7
正解:D
質問 # 76
What will happen when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
int fun(int);
int main()
{
int *x = new int;
*x=10;
cout << fun(*x);
return 0;
}
int fun(int i)
{
return i*i;
}
- A. It will print: 100
- B. It will print: 1
- C. It will print: 10
- D. It will print: 101
正解:A
質問 # 77
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; using namespace myNamespace2;
- B. using myNamespace1::y; using myNamespace2::x;
- C. using namespace myNamespace1;
- D. using myNamespace2::y; using myNamespace1::x;
正解:B
質問 # 78
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main()
{
int x=20;
int *ptr;
ptr = &x;
cout<<*ptr;
return 0;
}
- A. It prints: 0
- B. It prints: 2
- C. It prints address of ptr
- D. It prints: 20
正解:D
質問 # 79
What happens if you try to compile and run this program?
#include <iostream>
using namespace std;
int main (int argc, const char * argv[])
{
print("Test");
return 0;
}
void print(int c[])
{
cout<<c;
}
- A. Program terminates abnormally
- B. Compilation fails
- C. None of these
- D. It prints: Test
正解:B
質問 # 80
......
注目のCPA-21-02豪華セット試験ガイドで最速合格を目指そう:https://www.jpntest.com/shiken/CPA-21-02-mondaishu
CPA-21-02試験ガイド豪華セットで最速合格を目指そう:https://drive.google.com/open?id=1WEI6ECzJ5Rhly0RCQ5EZUCeLUAhSBwZn