What is the output of the program if character "1" is supplied as input?
#include
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';
}
}
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;
}
A. It prints: float exception. Exception Nr. 5.2
B. It prints: int exception. Exception Nr. 20
C. It prints: An exception occurred
D. Compilation Error
What is the meaning of the following declaration? (Choose two.) char **ptr;
A. ptr is a pointer to a pointer to char
B. ptr is a pointer to char*
C. ptr is a pointer to a pointer to a pointer to char
D. ptr is a pointer to char
What is the output of the program?
#include
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;
}
A. It prints: 2020
B. It prints: 1020
C. It prints: 20
D. It prints: 10
What is the expected result of the following program?
A. It prints: 4
B. The program enters an infinite loop
C. It prints: 42
D. It prints: 420
What happens when you attempt to compile and run the following code?
#include
#include
using namespace std;
class complex{
double re;
double im;
public:
complex() : re(1),im(0.4) {}
bool operator==(complex andt);
};
bool complex::operator == (complex andt){
if((this?>re == t.re) andand (this?>im == t.im))
return true;
else
return false;
}
int main(){
complex c1,c2;
if (c1==c2)
cout << "OK";
else {
cout << "ERROR";
}
}
A. It prints: OK
B. It prints: ERROR
C. Compilation error
D. Runtime error.
Which code, inserted at line 18, generates the output "AB"
#include
using namespace std;
class A
{
public:
void Print(){ cout<< "A";}
void Print2(){ cout<< "a";}
};
class B:public A
{
public:
void Print(){ cout<< "B";}
void Print2(){ cout<< "b";}
};
int main()
{
B ob2;
//insert code here
ob2.Print();
}
A. ob2?>A::Print();
B. ob2.B::Print();
C. ob2?>B::Print();
D. ob2.A::Print();
What will happen if the memory cannot be allocated?
A. The program will print: Standard exception
B. The program will print: Unknown exception
C. The program will cause a compilation error
D. The program will print: Error allocating memory
What will happen when you attempt to compile and run the following code?
#include
#include
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: 101
C. It will print: 10
D. It will print: 1
What happens when you attempt to compile and run the following code? #include
using namespace std;
int min(int a, int b);
int main()
{
int b=10;
b = min(5,20);
cout << b;
return 0;
}
int min(int a, int b)
{
if (a
return(a);
else
return(b);
}
A. It prints: 10
B. It prints: 20
C. It prints: 5
D. It prints: 0
What happens when you attempt to compile and run the following code?
#include
#include
using namespace std;
class A {
int x;
protected:
int y;
public:
int z;
};
class B : private A {
string name;
public:
void set() {
x = 1;
}
void Print() {
cout << x;
}
};
int main () {
B b;
b.set();
b.Print();
return 0;
}
A. It prints: 123
B. It prints: 1
C. It prints: ?123
D. Compilation error
Nowadays, the certification exams become more and more important and required by more and more enterprises when applying for a job. But how to prepare for the exam effectively? How to prepare for the exam in a short time with less efforts? How to get a ideal result and how to find the most reliable resources? Here on Vcedump.com, you will find all the answers. Vcedump.com provide not only C++ Institute exam questions, answers and explanations but also complete assistance on your exam preparation and certification application. If you are confused on your CPA-21-02 exam preparations and C++ Institute certification application, do not hesitate to visit our Vcedump.com to find your solutions here.