Last Updated on November 1, 2019 by Admin
CPA Mock Test Online
CPA -- Mock Test
Quiz-summary
0 of 40 questions completed
Questions:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
Information
CPA — Mock Test
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading...
You must sign in or sign up to start the quiz.
You have to finish following quiz, to start this quiz:
Results
0 of 40 questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 points, (0)
Average score |
|
Your score |
|
Categories
- Not categorized 0%
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- Answered
- Review
-
Question 1 of 40
1. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main (int argc, const char *argv[])
{
int a = 1, b = 1, c = 1, i = 1;
i = b < a < c;
cout << i;
return 0;
}
Correct
Incorrect
-
Question 2 of 40
2. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main()
{
int val = 0, *adr = &val;
cout << *val;
return 0;
}
Correct
Incorrect
-
Question 3 of 40
3. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main(){
int i = 2;
if (i‑‑==1)
cout << i;
else
cout << i + 1;
return 0;
}
Correct
Incorrect
-
Question 4 of 40
4. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
class One
{
public:
void out(){ cout<<“One”;}
};
int main()
{
One arr[2];
for(int i = 0; i < 1; i++)
arr[i].out();
}
Correct
Incorrect
-
Question 5 of 40
5. Question
1 pointsVariable “c” in class B, will be…
class A {
int a;
protected:
int b;
public:
int c;
};
class B : public A {
float f;
public:
void foo() {
cout << f << c;
}
};
Correct
Incorrect
-
Question 6 of 40
6. Question
1 pointsWhat is the output of the program given below?
#include <iostream>
using namespace std;
int main (int argc, const char * argv[])
{
double dbl = ‑5.55;
cout << (int)dbl;
}
Correct
Incorrect
-
Question 7 of 40
7. Question
1 pointsWhat is the output of the program given below?
#include <iostream>
using namespace std;
void foo(int ¶meter)
{
parameter *= 2;
}
int main()
{
int var = 2;
foo(var);
cout << var;
return 0;
}
Correct
Incorrect
-
Question 8 of 40
8. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main()
{
int a = ‑1, *p = &a;
cout << ((p == NULL) ? 1.1 : 2.2);
return 0;
}
Correct
Incorrect
-
Question 9 of 40
9. Question
2 pointsWhich of the following statements are correct about the following array?
char array[255];
Correct
Incorrect
-
Question 10 of 40
10. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main(){
int *Int = new int;
*Int = 1 / 2 * 2 / 1. * 2. / 4 * 4;
cout << *Int;
return 0;
}
Correct
Incorrect
-
Question 11 of 40
11. Question
2 pointsWhich of the following is user defined data type?
1:
enum Enum {One, Two, Three};
2:
int Int=2;
3:
char Char;
4:
struct Struct
{
char Char;
int Int;
};
Correct
Incorrect
-
Question 12 of 40
12. Question
1 pointsWhich code, inserted into the One class, generates the output “123”?
#include <iostream>
using namespace std;
class One {
public:
//insert code here
};
class Two : public One {
public:
void foo(){ cout << 2; }
};
class Three : public Two {
public:
void foo(){ cout << 3; }
};
int main()
{
One o1;
Two o2;
Three o3;
One *o = &o1;
o‑>foo();
o = &o2; o‑>foo();
o = &o3; o‑>foo();
}
Correct
Incorrect
-
Question 13 of 40
13. Question
1 pointsWhich code, inserted into the main function, generates the output “a 2”?
#include <iostream>
using namespace std;
namespace Space
{ char a = ‘a’, b = ‘b’; }
int a = 1, b = 2;
int main () {
// insert code here
cout << a << ” ” << b;
return 0;
}
Correct
Incorrect
-
Question 14 of 40
14. Question
1 pointsWhat is the output of the program given below?
#include <iostream>
using namespace std;
int main ()
{
int i = 0;
cout << i;
{ int i = 1; cout << i; }
{ int i = 2; }
cout << i;
return 0;
}
Correct
Incorrect
-
Question 15 of 40
15. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
class foo {
int p;
protected:
int q;
public:
int r;
};
class bar : public foo {
public:
void assign() {
p = q = r = 2;
}
void out() { cout << q << r; }
};
int main () {
bar b;
b.assign();
b.out();
return 0;
}
Correct
Incorrect
-
Question 16 of 40
16. Question
1 pointsWhat is the output of this program?
#include <iostream>
using namespace std;
int main()
{
char str[] = “Hello\0World\0”;
cout << str;
return 0;
}
Correct
Incorrect
-
Question 17 of 40
17. Question
1 pointsWhich code, inserted into the main function, generates the output “za”?
#include <iostream>
using namespace std;
namespace SpaceOne { char a = ‘a’; }
namespace SpaceTwo { char a = ‘z’; }
int main () {
// insert code here
return 0;
}
Correct
Incorrect
-
Question 18 of 40
18. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main()
{
char i = ‘1’;
switch(i)
{
case ‘1’:
cout<<“Hello “;
case ‘2’:
cout<<“world “; break;
case ‘3’:
cout<<“!”;
} return 0;
}
Correct
Incorrect
-
Question 19 of 40
19. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <cstdlib>
#include <iostream>
using namespace std;
char c;
char* inc(char par1, int par2)
{
c = par1 + par2;
return &c;
}
int main()
{
int a = ‘a’, b = 3;
char *f;
f = inc(a,b);
cout << *f;
return 0;
}
Correct
Incorrect
-
Question 20 of 40
20. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
#include <exception>
using namespace std;
class a
{
public: virtual string whose()
{ return “mine”; }
};
class b
{
public: virtual string whose()
{ return “yours”; }
};
int main () {
a b;
try { throw b; }
catch (a& e) { cout << e.whose() << endl; }
return 0;
}
Correct
Incorrect
-
Question 21 of 40
21. Question
1 pointsWhich code, inserted into the B class, generates the output “ef”?
#include <iostream>
#include <string>
using namespace std;
class Alpha {
int p;
protected:
int q;
public:
int r;
Alpha():p(2),q(3),r(4) {}
};
class Beta : public Alpha {
string s;
public:
int y;
void assign() { y = 4; s = “f”; }
void out() {
// insert code here
}
};
int main () {
Beta b;
b.assign();
b.out();
return 0;
}
Correct
Incorrect
-
Question 22 of 40
22. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int sub(int x, int y)
{
x ‑= y;
return x;
}
int main()
{
int a = 0, b = 1, c, d;
c = sub(a,b);
d = sub(c,b);
cout << c << d;
return 0;
}
Correct
Incorrect
-
Question 23 of 40
23. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
class one {
public :
void foo() { cout << 1; }
};
class two {
public :
void foo() { cout << 2; }
};
int main() {
two objects[2];
two *object = objects;
for(int i = 0; i < 2; i++)
(object++)‑>foo();
return 0;
}
Correct
Incorrect
-
Question 24 of 40
24. Question
1 pointsWhat is the output of this program if the string “bar” is supplied as input?
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s1 = “foo”;
string s2;
getline(cin,s2);
cout << s2.append(s1);
return( 0 );
}
Correct
Incorrect
-
Question 25 of 40
25. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
char fun(char *p)
{
char c = *p;
(*p)++;
return c;
}
int main()
{
char array[3]={‘a’, ‘b’, ‘c’};
fun(array + 1);
cout << fun(array + 1);
return 0;
}
Correct
Incorrect
-
Question 26 of 40
26. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main(void)
{
string s;
s = “abcd”;
s.append(s);
s.resize(s.size() / 2);
cout << s;
return 0;
}
Correct
Incorrect
-
Question 27 of 40
27. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
class C1 {
friend class C2;
protected: int y;
public: int z;
private: int x;
public: C1() { x = y = z = 11; }
};
class C2 {
public: C1 a;
C2 () { a.x = 22; };
void foo() {
cout << a.x << a.y << a.z;
}
};
int main()
{
C2 c;
c.foo();
return 0;
}
Correct
Incorrect
-
Question 28 of 40
28. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
int f(int a)
{
return a + a;
}
int main()
{
int i = 0;
for(int a = 0; a < 2; a++)
i = f(i + 1);
cout << i;
return 0;
}
Correct
Incorrect
-
Question 29 of 40
29. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
class Zero
{ public: void out(){ cout << 0;} };
class One : public Zero
{ public: void out(){ cout << 1;} };
class Two : public Zero
{ public: void out(){ cout << 2;} };
int main()
{
Zero *obj;
One obj1;
obj = &obj1;
obj‑>out();
Two obj2;
obj = &obj2;
obj‑>out();
return 0;
}
Correct
Incorrect
-
Question 30 of 40
30. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
class SupClass {
public:
void show(int par){ cout << par + 1;}
};
class SubClass : public SupClass {
public:
void show(float par){ cout << par + 2;}
};
int main()
{
SubClass o;
o.show(2.0);
}
Correct
Incorrect
-
Question 31 of 40
31. Question
3 pointsWhich code, inserted into function main, generates the output “abba”?
#include <iostream>
#include <string>
using namespace std;
string fun(string s)
{
return s.substr(0,1)+s.substr(1,1)+s.substr(1,1)+s.substr(0,1);
}
int main()
{
string *s = new string(“ab”);
//insert code here
return 0;
}
Correct
Incorrect
-
Question 32 of 40
32. Question
1 pointsWhat is the output of this program?
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s1[]= {“A”,”Z”};
string s=””;
for (int i=0; i<2; i++)
cout << s.append(s1[i]).insert(1,”_”);
return( 0 );
}
Correct
Incorrect
-
Question 33 of 40
33. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main()
{
float x = 0.9, y=‑0.5;
int i,j = 1;
i = x + j + y;
cout << i;
return 0;
}
Correct
Incorrect
-
Question 34 of 40
34. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main(){
int i = 1;
if (‑‑i == 1) {
cout << i;
} else {
cout << ‑‑i;
}
return 0;
}
Correct
Incorrect
-
Question 35 of 40
35. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int var = ‑1;
int static Static(int i)
{
static int y = 0;
y += ++i;
return y;
}
int main()
{
var++;
Static(var++);
cout << var << Static(var);
}
Correct
Incorrect
-
Question 36 of 40
36. Question
1 pointsWhat is the output of the program given below?
#include <iostream>
using namespace std;
int main ()
{
enum answer { yes, no, whoknows };
enum answer a[3];
a[0] = no;
a[2] = yes;
a[1] = whoknows;
for(int i = 0; i < 3; i++)
cout << a[i];
return 0;
}
Correct
Incorrect
-
Question 37 of 40
37. Question
1 pointsHow can we pass arguments to functions?Correct
Incorrect
-
Question 38 of 40
38. Question
1 pointsWhich code, inserted into the Class, generates the output “abcd”?
#include <iostream>
using namespace std;
class Class {
public:
static char value;
Class() { value++; };
~Class () { value++; };
//insert code here
void print() { cout << value;}
};
char Class::value = ‘a’;
int main () {
Class a,*b;
b = new Class();
b‑>set(‘a’);
b‑>print();
delete b;
a.print();
a.set(‘c’);
a.print();
a.set();
a.print();
return 0;
}
Correct
Incorrect
-
Question 39 of 40
39. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
void fun(int *i)
{
*i = *i >> *i ‑ 1;
}
using namespace std;
int main()
{
int i = 2;
fun(&i);
cout << i;
return 0;
}
Correct
Incorrect
-
Question 40 of 40
40. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
#define A 0
#define B A+1
#define C 1‑B
int main() {
cout << C;
return 0;
}
Correct
Incorrect