(Aug-2024) Latest CPA-21-02 Dumps for Success in Actual C++ Institute Certified
Changing the Concept of CPA-21-02 Exam Preparation 2024
NEW QUESTION # 147
Which of the following statements are correct about an array?
int tab[10];
- A. The expression tab[1] designates the very first element in the array.
- B. The expression tab[9] designates the last element in the array.
- C. It is necessary to initialize the array at the time of declaration.
- D. The array can store 10 elements.
Answer: B,D
NEW QUESTION # 148
What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
class complex{
double re, im;
public:
complex() : re(1),im(0.4) {}
complex operator?(complex &t);
void Print() { cout << re << " " << im; }
};
complex complex::operator? (complex &t){
complex temp;
temp.re = this?>re ? t.re;
temp.im = this?>im ? t.im;
return temp;
}
int main(){
complex c1,c2,c3;
c3 = c1 ? c2;
c3.Print();
}
- A. It prints: 0 0
- B. It prints: 1 0.4
- C. It prints: 1 0.8
- D. It prints: 2 0.8
Answer: A
NEW QUESTION # 149
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: Hello:
- B. It prints: Hello:1
- C. Runtime error.
- D. It prints: 10
Answer: C
NEW QUESTION # 150
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main(){
int i = 1;
for(i=10; i>-1; i/=2) {
if(!i)
break;
}
cout << i;
return 0;
}
- A. Compilation error
- B. It prints: -1
- C. It prints: 0
- D. It prints: 1
Answer: C
NEW QUESTION # 151
What happens when you attempt to compile and run the following code?
- A. It prints: Tesc
- B. It prints an empty line
- C. It prints: st
- D. It prints: T
Answer: A
NEW QUESTION # 152
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();
}
- A. It prints: 10
- B. Compilation error
- C. It prints: 0
- D. It prints: ?1
Answer: A
NEW QUESTION # 153
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
#include <iostream>
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. Runtime error.
- B. Compilation error
- C. It prints: from First
- D. It prints: from Firstfrom First
Answer: D
NEW QUESTION # 154
What will be the output of the program?
#include <iostream>
#include <string>
using namespace std;
int fun(int);
int main()
{
float k=3;
k = fun(k);
cout<<k;
return 0;
}
int fun(int i)
{
i++;
return i;
}
- A. 5
- B. 0
- C. 1
- D. 2
Answer: C
NEW QUESTION # 155
What is the output of the program given below?
#include <iostream>
using namespace std;
int main (int argc, const char * argv[])
{
float f=?10.501;
cout<<(int)f;
}
- A. ?11
- B. ?10
- C. 0
- D. 1
Answer: B
NEW QUESTION # 156
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
class complex{
double re;
double im;
public:
complex() : re(0),im(0) {}
complex(double x) { re=x,im=x;};
complex(double x,double y) { re=x,im=y;}
void print() { cout << re << " " << im;}
};
int main(){
complex c1;
c1 = 3.0;
c1.print();
return 0;
}
- A. Compilation error
- B. It prints: 3 3
- C. It prints: 0 0
- D. It prints: 1 1
Answer: B
NEW QUESTION # 157
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main()
{
int i = 5;
cout<<"Hello World" << ++i;
return 0;
}
- A. It prints: Hello World6
- B. It prints: World
- C. It prints: Hello World5
- D. It prints: Hello
Answer: A
NEW QUESTION # 158
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;
}
- A. It prints: A string parameterA no parametersB int parameterA object A parameter
- B. It prints: A no parametersA no parametersB string parameter
- C. It prints: A no parametersB string parameter
- D. It prints: A no parametersA no parameters
Answer: A
NEW QUESTION # 159
Point out an error in the program.
#include <iostream>
using namespace std;
int main()
{
const int x=1;
int const *y=&x;
cout<<*y;
return 0;
}
- A. cannot convert from 'const int *' to 'int *const'
- B. Compilation error
- C. No error
- D. Error: unknown pointer conversion
Answer: C
NEW QUESTION # 160
Which of the following is a logical operator?
- A. !
- B. &&
- C. &
- D. ||
Answer: A,B,D
NEW QUESTION # 161
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int op(int x, int y);
float op(int x, float y);
int main()
{
int i=1, j=2, k;
float f=0.3;
k = op(i, j);
cout<< k << "," << op(0, f);
return 0;
}
int op(int x, int y)
{
return x+y;
}
float op(int x, float y)
{
return x?y;
}
- A. It prints: 3,?0.3
- B. It prints: 0,0
- C. It prints: 3,1
- D. It prints: 3,0
Answer: A
NEW QUESTION # 162
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: A B
- B. It prints: B B
- C. It prints: B A
- D. It prints: A A
Answer: B
NEW QUESTION # 163
......
CPA-21-02 Exam Crack Test Engine Dumps Training With 256 Questions: https://actualtests.passsureexam.com/CPA-21-02-pass4sure-exam-dumps.html