Want to pass your C++ Certified Associate Programmer CPA exam in the very first attempt? Try Pass2lead! It is equally effective for both starters and IT professionals.
VCE
What will happen when you attempt to compile and run the following code? #include
using namespace std;
int main()
{
const char *s;
char str[] = "Hello ";
s = str;
while(*s) {
cout << *++s;
*s++;
}
return 0;
}
A. It will print:"el "
B. The code will not compile.
C. It will print:"Hello "
D. It will print garbage value
What happens when you attempt to compile and run the following code?
#include
using namespace std;
int main()
{
union un
{
int x;
char c;
};
union un u1 = {10};
union un u2 = {'a'};
union un u3 = {20, 'a'};
cout< cout< cout< return 0; } A. It prints: 10aa B. It prints: 10a20a C. It prints: 1a D. Compilation error
What happens when you attempt to compile and run the following code?
#include
using namespace std;
class First
{
public:
First() { cout << "Constructor";}
~First() { cout << "Destructor";}
void Print(){ cout<<"from First";}
};
int main()
{
First FirstObject;
FirstObject.Print();
}
A. It prints: Constructorfrom First
B. It prints: Constructorfrom FirstDestructor
C. It prints: Constructorfrom FirstDestructorDestructor
D. Compilation error at line 16