What is the output of the program if characters 't', 'e', 's' and 't' enter are supplied as input?
#include
#include
using namespace std;
int main()
string s;
getline( cin, s );
cout << s << " " << s.length();
return( 0 );
}
A. It prints: test 4
B. It prints: test
C. It prints: test 5
D. It prints: 4
Which of the following is a logical operator?
A. and
B. andand
C. ||
D. !
What happens when you attempt to compile and run the following code?
#include
using namespace std;
class A {
public:
virtual void Print()=0;
};
class B:public A {
public:
virtual void Print() { cout<< "B"; }
};
class C:public A {
public:
virtual void Print() { cout<< "C"; }
};
int main()
{
B ob2;
C ob3;
A *obj;
obj = andob2;
obj?>Print();
obj = andob3;
obj?>Print();
}
A. It prints: BC
B. It prints: CB
C. It prints: CC
D. It prints: BB
Given:
#include
#include
using namespace std;
int main () {
try
{
int * myarray= new int[1000];
}
catch (bad_allocand)
{
cout << "Error allocating memory";
}
catch (exceptionand e)
{
cout << "Standard exception";
}
catch (...)
{
cout << "Unknown exception";
}
return 0;
}
What will happen if we use the operator "new" and the memory cannot be allocated?
A. It prints: Error allocating memory
B. It prints: Standard exception
C. It prints: Unknown exception
D. Compilation error
What happens when you attempt to compile and run the following code?
#include
using namespace std;
class A
{
public:
virtual void Print(){ cout<<"A";}
};
class B:public A
{
public:
void Print(){ cout<< "B";}
};
int main()
{
A *obj;
A ob1;
obj = andob1;
obj?>Print();
B ob2;
obj = andob2;
obj?>Print();
}
A. It prints: AB
B. It prints: AA
C. It prints: BA
D. It prints: BB
What happens when you attempt to compile and run the following code?
#include
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 = andob1;
obj?>Print();
B ob2;
obj = andob2;
obj?>Print();
}
A. It prints: AB
B. It prints: AA
C. It prints: BA
D. It prints: BB
What happens when you attempt to compile and run the following code?
#include
using namespace std;
void fun(int*);
int main()
{
int i=2;
fun(andi);
cout<
return 0;
}
void fun(int *i)
{
*i = *i**i;
}
A. It prints: 1
B. It prints: 4
C. It prints: 10
D. It prints: 0
Which statement should be added in the following program to make work it correctly?
using namespace std;
int main (int argc, const char * argv[])
{
cout<<"Hello";
}
A. #include
B. #include
C. #include
D. #include
Point out an error in the program.
#include
using namespace std;
int main()
{
char s1[] = "Hello";
char s2[] = "world";
char *const ptr = s1;
*ptr = 'a';
ptr = s2;
return 0;
}
A. No error
B. Cannot modify a const object
C. Compilation error at line 9
D. None of these
What happens when you attempt to compile and run the following code?
#include
using namespace std;
#include
using namespace std;
class First
{
public:
void Print(){ cout<<"from First";}
};
int main()
{
First t[2];
for (int i=0; i<2; i++)
t[i].Print();
}
A. It prints: from First
B. It prints: from Firstfrom First
C. Compilation error
D. Runtime 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.