CPA-21-02 無料問題集「C++ Institute CPA - C++ Certified Associate Programmer」

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

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 C:public A {
public:
virtual void Print()=0;
};
int main()
{
C obj3;
obj3?>Print();
}

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

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

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";}
B(int s) { cout << "B int parameter";}
};
int main () {
A a2("Test");
B b1(10);
B b2(b1);
return 0;
}

What is the output of the program given below?
#include <iostream>
using namespace std;
int main (int argc, const char * argv[])
{
int i=10;
{
int i=0;
cout<<i;
}
cout<<i;
return 0;
}

What is the output of the program?
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s1="Hello";
string s2="World";
s1+=s2;
cout << s1;
return( 0 );
}

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

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";}
};
class C:public B {
public:
void Print(){ cout<< "C";}
};
int main()
{
A ob1;
B ob2;
C ob3;
B *obj;
obj = &ob2;
obj?>Print();
obj = &ob3;
obj?>Print();
}

What is the output of the program if character 4 is supplied as input?
#include <iostream>
using namespace std;
int main () {
int c;
cin >> c;
try
{
switch (c)
{
case 1:
throw 20;
case 2:
throw 5.2f;
case 3:
throw 'a';
default:
cout<<"No exception";
}
}
catch (int e)
{ cout << "int exception. Exception Nr. " << e; }
catch (float e)
{ cout << "float exception. Exception Nr. " << e; }
catch (...)
{ cout << "An exception occurred."; }
return 0;
}

Which of the following is a logical operator?

正解:B、C、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;
}

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

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

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

What happens if characters 'w', 'o', 'r', 'l' and 'd' are entered as input?
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s1 = "Hello";
string s2;
getline( cin, s2 );
cout << s1 + s2;
return( 0 );
}

What is the output of the program?
#include <iostream>
using namespace std;
class BaseC
{
int i;
public:
BaseC() { i=?1;}
BaseC(int i) { i=i; }
void seti(int a) { i = a; };
void Print() { cout << i; }
};
int main()
{
BaseC *o = new BaseC();
o?>seti(10);
o?>Print();
}

What is the output of the program?
#include <iostream>
using namespace std;
class Base {
static int age;
public:
Base () {};
~Base () {};
void setAge(int a=10) {age = a;}
void Print() { cout << age;}
};
int Base::age=0;
int main () {
Base a,*b;
b = new Base();
a.setAge();
b?>setAge(20);
a.Print();
b?>Print();
return 0;
}

弊社を連絡する

我々は12時間以内ですべてのお問い合わせを答えます。

オンラインサポート時間:( UTC+9 ) 9:00-24:00
月曜日から土曜日まで

サポート:現在連絡