Last Updated on November 24, 2018 by Admin
CPA Final Test Online 100%
CPA -- Final Test
Time limit: 0
Quiz-summary
0 of 50 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
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
Information
CPA -- Final 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 50 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
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- Answered
- Review
-
Question 1 of 50
1. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> #include <string> using namespace std; class Class1 { char a; protected: char b; public: char c; Class1() { a='a'; b='b'; c='c'; } }; class Class2 : public Class1 { char d; public: void set() { c = 'e'; d = 'd'; } }; int main () { Class2 a; a.set(); cout << a.c << a.d; return 0; }Correct
Incorrect
-
Question 2 of 50
2. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> using namespace std; int main() { int i = 8; do { i‑‑; cout << i‑‑; } while(i); return 0; }Correct
Incorrect
-
Question 3 of 50
3. Question
1 pointsWhich code, inserted into the main function, generates the output "12"? #include <iostream> #include <string> using namespace std; string fun(string s1, string s2) { return s1 + s2; } int main() { string s="1", *t = &s; //insert code here return 0; }Correct
Incorrect
-
Question 4 of 50
4. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> #include <string> using namespace std; class One { public: float f; One(float f) { this ‑> f = f; } }; class Two { public: float f; Two (One o) { this ‑> f = o.f; } void foo() { cout << (int)f; } }; int main() { One o1(3.14); Two o2 = o1; o2.foo(); }Correct
Incorrect
-
Question 5 of 50
5. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> using namespace std; int main() { const char c = '!'; const char *p; p = &c; *p = '?'; cout << *p; return 0; }Correct
Incorrect
-
Question 6 of 50
6. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> using namespace std; class X1 { public: virtual void foo() = 0; }; class X2 : public X1 { public: virtual void foo() { cout << "X2"; } }; class X3 : public X1 { public: virtual void foo() { cout << "X3"; } }; int main() { X1 *a = new X2(), *b = new X3(); b‑>foo(); a‑>foo(); return 0; }Correct
Incorrect
-
Question 7 of 50
7. Question
1 pointsWhat is the output of the program given below? #include <iostream> using namespace std; int main (int argc, const char *argv[]) { float B = 32; { char B = '1'; cout << B; } { int B = 2; cout << B; } cout << B; return 0; }Correct
Incorrect
-
Question 8 of 50
8. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> using namespace std; class Sup { public: virtual void out() { cout << "p"; } }; class Sub : public Sup { public: virtual void out() { cout << "b"; } }; int main() { Sub sub; Sup *sup; sup = ⊂ sup‑>out(); sub.out(); return 0; }Correct
Incorrect
-
Question 9 of 50
9. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> using namespace std; int doit(int i, int j = 0) { return (i * j); } int main () { cout << doit(doit(1,2)); return 0; }Correct
Incorrect
-
Question 10 of 50
10. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> using namespace std; int doit(int x) { return x << 1; } int main(){ int i; i = doit(1) || doit(0); cout << i; return 0; }Correct
Incorrect
-
Question 11 of 50
11. Question
1 pointsVariable "y" in class Y, will be... class X { private: int x; protected: int y; public: int z; }; class Y : protected X { };Correct
Incorrect
-
Question 12 of 50
12. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> using namespace std; #define CALL(param) { if(param) cout << param++; } int main() { int i = 1; CALL(i); cout << i; return 0; }Correct
Incorrect
-
Question 13 of 50
13. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> using namespace std; int main(){ int a = 0; if (++a == 1) { cout << (a >> 1); } else { cout << (a); } return 0; }Correct
Incorrect
-
Question 14 of 50
14. Question
1 pointsWhat happens if we use the operator new and the memory cannot be allocated? #include <iostream> #include <exception> using namespace std; int main () { long i = 2000000000; try { char *text = new char[i]; } catch (bad_alloc& e) { cout << "1"; } catch (exception& e) { cout << "2"; } catch (...) { cout << "3"; } return 0; }Correct
Incorrect
-
Question 15 of 50
15. Question
1 pointsWhat will be the output of the program? #include <iostream> #include <string> using namespace std; struct S { char *p; }; class C { S s; public: C() { s.p = new char; *s.p = 'A'; } void p() { cout << ++(*s.p); } }; int main() { C *c = new C(); c‑>p(); return 0; }Correct
Incorrect
-
Question 16 of 50
16. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> using namespace std; class A { public: void out(){ cout << "A"; } }; class B : public A { public: void out(){ cout << "B"; } }; int main() { A *a; a = new A(); a ‑> out(); a = new B(); a ‑> out(); return 0; }Correct
Incorrect
-
Question 17 of 50
17. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> #include <cstdarg> using namespace std; int calculate(int &val, int arg) { val *= arg; return arg; } int main() { int i = 1; int j = calculate(i,2); cout << i << j; return 0; }Correct
Incorrect
-
Question 18 of 50
18. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> #include <string> using namespace std; class cmplx{ double re, im; public: cmplx() : re(1),im(1) {} cmplx(double r, double i) : re(r),im(i) {} cmplx operator+(cmplx &); void out() { cout << "(" << re << "," << im << ")"; } }; cmplx cmplx::operator+ (cmplx &a){ cmplx c(this‑>re + a.re, this‑>im + a.im); return c; } int main(){ cmplx x(1,2),y,z; z = x + y; z.out(); return 0; }Correct
Incorrect
-
Question 19 of 50
19. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> using namespace std; class cmplx{ double re,im; public: cmplx() : re(0),im(0) {} cmplx(double x) { re = im = x; } cmplx(double x,double y) { re = x; im = y; } void out() { cout << "(" << re << "," << im << ")"; } }; int main(){ cmplx c(1,2), cc(c); cc.out(); return 0; }Correct
Incorrect
-
Question 20 of 50
20. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> #include <string> using namespace std; class One { char value; public: One() { value = 'A'; } One(char v) : value(v) {} void set(char c) {this ‑> value = c; } void set() { this ‑> value = 'd'; } char get(){ return value; } }; int main() { One o1,*o2; o2 = new One('b'); One *p; p = &o1; p ‑> set(); p = o2; p ‑> set('c'); cout << o2‑>get() ‑ o1.get(); return 0; }Correct
Incorrect
-
Question 21 of 50
21. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> using namespace std; class Alpha { public: char out(){ return 'A'; } }; class Beta : public Alpha { public: virtual char out(){ return 'B'; } }; class Gamma : public Beta { public: char out(){ return 'G'; } }; int main() { Alpha *a = new Alpha(); Alpha *b = new Beta(); Alpha *c = new Gamma(); cout << (a‑>out()) << (b‑>out()) << (c‑>out()); return 0; }Correct
Incorrect
-
Question 22 of 50
22. Question
1 pointsWhich code, inserted into the function main, generates the output "03"? #include <iostream> using namespace std; class Uno { public: void foo(){ cout << "0";} void bar(){ cout << "1";} }; class Due : public Uno { public: void foo(){ cout << "2";} void bar(){ cout << "3";} }; int main() { Due d; // insert code here d.bar(); }Correct
Incorrect
-
Question 23 of 50
23. Question
1 pointsVariable "r" in class C3, will be... #include <iostream> using namespace std; class C1 { public int p; private int q; protected int r; }; class C2 : private C1 {}; class C3 : public C2 {};Correct
Incorrect
-
Question 24 of 50
24. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> using namespace std; int main() { const PI = 3.14; const PI2 = PI * PI; cout << PI2; return 0; }Correct
Incorrect
-
Question 25 of 50
25. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> #include <string> using namespace std; const int size = 3; class Uno { public: int n; Uno() { n = 1; } Uno(int v) { n = v;} }; class Due : public Uno { public: int *arr; Due() : Uno() { arr = new int[n]; } Due(int a) : Uno(a) { arr = new int[n]; } ~Due() { delete arr; } }; int main () { Due d(2); Due e; cout << d.n + e.n; return 0; }Correct
Incorrect
-
Question 26 of 50
26. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> using namespace std; int main() { int x = ‑2, y; float f = 2.5, g; g = x; y = f; cout << (int)g / y; return 0; }Correct
Incorrect
-
Question 27 of 50
27. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> #include <string> using namespace std; class Uno { public: int Int; }; class Due : public Uno { public: Due() { Int = 2;} Due(int x) { Int = x == 0 ? 2 : x ‑ 2; } }; int main () { Due d,d2(0); cout << d.Int ‑ d2.Int; return 0; }Correct
Incorrect
-
Question 28 of 50
28. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> using namespace std; namespace OuterSpace { int x = 1; int y = 2; } namespace InnerSpace { float x = 3.0; float y = 4.0; } int main () { { using namespace InnerSpace; cout << x << " "; }{ using namespace OuterSpace; using InnerSpace::y; cout << y; } return 0; }Correct
Incorrect
-
Question 29 of 50
29. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> using namespace std; float doit(int a, int b) { return a * b; } float doit(float a, float b) { return a + b; } int main() { cout << doit(doit(1,2),doit(3.f,4.f)); return 0; }Correct
Incorrect
-
Question 30 of 50
30. Question
1 pointsWhat is the output of the program if the value of 1 is supplied as input? #include <iostream> using namespace std; class Uno { public: char Char; }; int main () { int swtch; Uno u; u.Char = '5'; cin >> swtch; try { switch (swtch) { case 3: throw 1; case 2: throw 3.f; case 1: throw u; } } catch (int e) { cout << e; } catch (Uno e) { cout << e.Char; } catch (...) { cout << "?"; } return 0; }Correct
Incorrect
-
Question 31 of 50
31. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> using namespace std; char max(char x, char y) { if(x > y) return y; else return x; } int main() { char chr = max('a', 'z'); cout << chr; return 0; }Correct
Incorrect
-
Question 32 of 50
32. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> using namespace std; bool compare(bool t, bool u) { return t < u; } int main() { cout << compare(true,false); return 0; }Correct
Incorrect
-
Question 33 of 50
33. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> #include <string> using namespace std; int main() { bool t[] = {false, true, false & true}; string u[2] = {"false", "true"}; bool *p; p = t + 2; cout << u[*p]; return 0; }Correct
Incorrect
-
Question 34 of 50
34. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> using namespace std; int main() { int i = 10; float f = 2.5; cout << float(i) / int(f); return 0; }Correct
Incorrect
-
Question 35 of 50
35. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> using namespace std; struct S { int a; char b; struct { float a; int b; } c; }; int main (int argc, const char *argv[]) { S s = { 1, 2, 3, 4 }; cout << s.c.a << s.c.b; }Correct
Incorrect
-
Question 36 of 50
36. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> #include <string> using namespace std; int main() { string s1 = "top"; string s2; s2.append(s1).append("down"); cout << s2; return( 0 ); }Correct
Incorrect
-
Question 37 of 50
37. Question
1 pointsWhat will be the output of this program? #include <iostream> #include <string> using namespace std; int boo(int v) { v++; return ++v; } int main() { float x = 3; x = boo(x); cout << x; return 0; }Correct
Incorrect
-
Question 38 of 50
38. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> using namespace std; int main() { int cnt = 10; do { cnt‑‑; if (cnt % 3 == 2) break; cout << cnt; } while(cnt); return 0; }Correct
Incorrect
-
Question 39 of 50
39. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> using namespace std; int main() { char *abc; abc = new char[26]; for(int i = 0; i < 26; i++) abc[i] = 'a' + i; cout << *(abc + 2); return 0; }Correct
Incorrect
-
Question 40 of 50
40. Question
1 pointsWhat is the output of this program? #include <iostream> #include <string> using namespace std; class Uno { public: Uno() { cout << "X"; } }; Uno foo(Uno d) { Uno e = d; return e; } int main() { Uno u; foo(u); return 0; }Correct
Incorrect
-
Question 41 of 50
41. Question
1 pointsWhat is the output of this program? #include <iostream> #include <string> using namespace std; class Uno { public: ~Uno() { cout << "X"; } }; void foo(Uno *d) { Uno e; *d = e; } int main() { Uno *u = new Uno; foo(u); delete u; return 0; }Correct
Incorrect
-
Question 42 of 50
42. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> using namespace std; int k = ‑1; class Class { public: char *adr; Class() { adr = new char[k]; } ~Class() { delete [] adr; } }; int fun(void) { Class object; return 0.5f; } int main() { fun(); return 0; }Correct
Incorrect
-
Question 43 of 50
43. Question
1 pointsWhat is the output of this program? #include <iostream> #include <string> using namespace std; struct Who { string nick; }; class She { Who *who; public: She() { who = new Who; who ‑> nick = "Jane"; } string out (){ return who ‑> nick; } }; int main() { She they[2]; for(int i = 0; i < 2; i++) cout << they[i].out(); return 0; }Correct
Incorrect
-
Question 44 of 50
44. Question
1 pointsWhat is the output of this program? #include <iostream> using namespace std; int main() { int i = 0; for(; i < 5; i++); cout << i; return 0; }Correct
Incorrect
-
Question 45 of 50
45. Question
1 pointsHow many times will the program print "HI!"? #include <iostream> using namespace std; int X = 5; int main() { cout << "HI!"; if(X‑‑ > 0) main(); return 0; }Correct
Incorrect
-
Question 46 of 50
46. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> using namespace std; int doit(int a, float b) { return a / b; } int main() { float x = doit(1.5f, 2l); cout << x << ":" << doit(1, 1.f); return 0; }Correct
Incorrect
-
Question 47 of 50
47. Question
3 pointsWhich code, inserted into class C, generates the output "by"? #include <iostream> #include <string> using namespace std; class Uno { protected: char y; public: char z; }; // insert code here { public: void set() { y = 'a'; z = 'z'; } void out() { cout << ++y << ‑‑z; } }; int main () { Due b; b.set(); b.out(); return 0; }Correct
Incorrect
-
Question 48 of 50
48. Question
1 pointsWhat happens when you attempt to compile and run the following code? #include <iostream> using namespace std; int main() { int i = 2; float f = 1.4; char c = 'a'; bool b = true; c += i + f + b; cout << c; return 0; }Correct
Incorrect
-
Question 49 of 50
49. Question
1 pointsWhich statement will you add in the following program to make it correct? #include <string> int main() { std::string s = "Here I am!"; std::cout << s; return 0; }Correct
Incorrect
-
Question 50 of 50
50. Question
1 pointsWhat is the output of this program? #include <iostream> #include <string> using namespace std; class Uno { int val; public: Uno(int x) { val = x; } int out() { return val; } void operator++(int var) { val += val; } }; ostream &operator<<(ostream &o, Uno u) { return o << u.out(); } int main() { Uno i(2); i++; cout << i; return 0; }Correct
Incorrect