Skip to content
  • Home
  • CCNA Labs
    • CCNA 1 LAB Activities (v6 & v7)
    • CCNA 2 LAB Activities (v6 & v7)
    • CCNA 3 LAB Activities (v6 & v7)
    • CCNA 4 Lab Activities
  • Linux
    • Linux Unhatched
    • Linux Essentials 2.0
    • Linux Essentials
    • Introduction to Linux I
    • Introduction to Linux II
  • Programming
    • PCAP – Programming Essentials in Python
    • CLA – Programming Essentials in C
    • CPA Programming Essentials in C++
  • About
    • Contact Us
    • Privacy Policy

CCNA 7 Exam Answers 2023

Go with our CCIE, Passed 100%

  • ITE
    • ITE - IT Essentials v7.0
    • ITE - IT Essentials v6.0
      • IT Essentials Lab 2019
    • ITE v5.0 Exam
    • Virtual Activity Laptop
    • Virtual Activity Desktop
  • NE
    • MF
  • CCNA
    • CCNA1
      • CCNA1 v7.0 – ITN
      • CCNA1 v6.0
    • CCNA2
      • CCNA2 v7.0 – SRWE
      • CCNA2 v6.0
    • CCNA3
      • CCNA3 v7.0 – ENSA
      • CCNA3 v6.0
    • CCNA4
      • CCNA4 v6.0
  • Cyber-Security
    • ITC – Introduction to Cybersecurity 2.1 (Level 1)
    • CE – Cybersecurity Essentials 1.1 (Level 2)
    • CCNA CyberOps 1.1 (Level 3)
  • Security
    • CCNA Security v2
  • DevNet
  • CCNA PT Lab 2023

CPA Chapter 8 Assessment Answers 100%

Last Updated on May 20, 2021 by Admin

CPA Chapter 8 Assessment Answers 100%

  1. What happens when you attempt to compile and run the following code?

    #include <iostream>
    using namespace std;
    class Int {
    public:
    int v;
    Int(int a) { v = a; }
    };

    int main() {
    Int i = 1;
    cout << i;
    return 0;
    }

    • It prints 0
    • It prints 1
    • Compilation fails
    • It prints 2
  2. What happens when you attempt to compile and run the following code?

    #include <iostream>
    using namespace std;
    class Int {
    public:
    int v;
    Int(int a) { v = a; }
    };

    ostream &operator <<(Int &a) {
    return cout << a.v;
    }

    int main() {
    Int i = 1;
    cout << i;
    return 0;
    }

    • Compilation fails
    • It prints 1
    • It prints 0
    • It prints 2
  3. What happens when you attempt to compile and run the following code?

    #include <iostream>
    using namespace std;
    class Int {
    public:
    int v;
    Int(int a) { v = a; }
    };

    ostream &operator <<(ostream &o, Int &a) {
    return o << –a.v;
    }

    int main() {
    Int i = 1;
    cout << i;
    return 0;
    }

    • It prints 1
    • It prints 0
    • It prints 2
    • Compilation fails
  4. What happens when you attempt to compile and run the following code?

    #include <iostream>
    using namespace std;
    class Int {
    public:
    int v;
    Int(int a) { v = a; }
    Int &operator–() {
    ++v;
    return *this;
    }
    };

    ostream &operator <<(ostream &o, Int &a) {
    return o << –a.v;
    }

    int main() {
    Int i = 2;
    cout << i;
    return 0;
    }

    • Compilation fails
    • It prints 2
    • It prints 1
    • It prints 0
  5. What happens when you attempt to compile and run the following code?

    #include <iostream>
    using namespace std;
    class Int {
    public:
    int v;
    Int(int a) { v = a; }
    Int &operator–() {
    ++v;
    ++v;
    return *this;
    }
    };

    ostream &operator <<(ostream &o, Int &a) {
    return o << a.v++;
    }

    int main() {
    Int i = 0;
    cout << –i;
    return 0;
    }

    • It prints 2
    • Compilation fails
    • It prints 0
    • It prints 1
  6. What happens when you attempt to compile and run the following code?

    #include <iostream>
    using namespace std;
    class Int {
    public:
    int v;
    Int(int a) { v = a; }
    Int &operator–() {
    ++v;
    return *this;
    }
    Int &operator–(int v) {
    v+=2;
    return *this;
    }

    };

    ostream &operator <<(ostream &o, Int &a) {
    a.v++;
    return o << a.v;
    }

    int main() {
    Int i = 0;
    –i ; i–;
    cout << i << i;
    return 0;
    }

    • It prints 23
    • It prints 21
    • It prints 12
    • It prints 10
    • Compilation fails
  7. What happens when you attempt to compile and run the following code?

    #include <iostream>
    using namespace std;
    class Int {
    public:
    int v;
    Int(int a) { v = a; }
    Int &operator++(int x) {
    v+=2;
    return *this;
    }

    };

    ostream &operator <<(ostream &o, Int &a) {
    return o << a.v;
    }

    int main() {
    Int i = 0;
    i++;
    cout << i << i.v;
    return 0;
    }

    • It prints 20
    • It prints 22
    • It prints 21
    • Compilation fails
  8. What happens when you attempt to compile and run the following code?

    #include <iostream>
    using namespace std;
    class Int {
    public:
    int v;
    Int(int a) { v = a; }
    Int &operator[](int x) {
    v+=x;
    return *this;
    }

    };

    ostream &operator <<(ostream &o, Int &a) {
    return o << a.v;
    }

    int main() {
    Int i = 2;
    cout << i.v ;
    cout << i[2];
    return 0;
    }

    • It prints 44
    • It prints 24
    • It prints 22
    • It prints 33
    • Compilation fails
  9. What happens when you attempt to compile and run the following code?

    #include <iostream>

    using namespace std;

    enum T { A, B, C };

    class Int {
    public:
    T v;
    Int(T a) { v = a; }

    };

    ostream &operator <<(ostream &o, Int &a) {
    return o << a.v;
    }

    int main() {
    Int i = B;
    cout << i;
    return 0;
    }

    • Compilation fails
    • It prints 0
    • It prints B
    • It prints 1
  10. What happens when you attempt to compile and run the following code?

    #include <iostream>

    using namespace std;

    enum T { A = 2, B = -1, C };

    class Int {
    public:
    T v;
    Int(T a) { v = a; }
    Int & operator++() { v = C; return *this; }
    };

    ostream &operator <<(ostream &o, Int &a) {
    ++a;
    return o << a.v;
    }

    int main() {
    Int i = B;
    cout << i;
    return 0;
    }

    • It prints C
    • It prints 0
    • Compilation fails
    • It prints 1
  11. What happens when you attempt to compile and run the following code?

    #include <iostream>

    using namespace std;

    enum T { A = 2, B = -1, C };

    class Int {
    public:
    T v;
    Int(T a) { v = a; }
    Int & operator++() { v += 2; return *this; }
    };

    ostream &operator <<(ostream &o, Int &a) {
    ++a;
    return o << a.v;
    }

    int main() {
    Int i = B;
    cout << i;
    return 0;
    }

    • It prints 0
    • Compilation fails
    • It prints 1
    • It prints 2
  12. What happens when you attempt to compile and run the following code?

    #include <iostream>

    using namespace std;

    enum T { A = 2, B = -1, C };

    T operator+(T t, int i) {
    switch(t) {
    case A: return T(0);
    case B: return static_cast<T>(2);
    default:return (T)1;
    }
    }

    int main() {
    T i = A + 2;
    cout << i;
    return 0;
    }

    • It prints 2
    • Compilation fails
    • It prints 1
    • It prints 0
  13. What happens when you attempt to compile and run the following code?

    #include <iostream>

    using namespace std;

    class N {
    public:
    float x;
    N() { x = 0.0; }
    N(float a) { x = a; }
    N(N &n) { x = n.x; }
    N &operator%(N &y) { return *new N((int)x % (int)y.x); }
    };

    int main() {
    N a(2.0),b(4.0);
    N c = a % b;
    cout << c.x;
    return 0;
    }

    • Compilation fails
    • It prints 2
    • It prints 0
    • It prints 1
  14. What happens when you attempt to compile and run the following code?

    #include <iostream>

    using namespace std;

    class N {
    public:
    float x;
    N() { x = 0.0; }
    N(float a) { x = a; }
    N(N &n) { x = n.x; }
    N &operator<<(N &y) { return *new N(x * 10); }
    };

    int main() {
    N a(2.0),b(4.0);
    N c = a << 1;
    cout << c.x;
    return 0;
    }

    • It prints 2
    • It prints 0
    • It prints 1
    • Compilation fails
  15. What happens when you attempt to compile and run the following code?

    #include <iostream>

    using namespace std;

    class N {
    public:
    float x;
    N() { x = 0.0; }
    N(float a) { x = a; }
    N(N &n) { x = n.x; }
    };

    N &operator=(N &y,float f) { return *new N(f); }

    int main() {
    N a;
    a = 2.0;
    cout << a.x;
    return 0;
    }

    • Compilation fails
    • It prints 2
    • It prints 1
    • It prints 0
  16. What happens when you attempt to compile and run the following code?

    #include <iostream>

    using namespace std;

    class N {
    public:
    float x;
    N() { x = 0.0; }
    N(float a) { x = a; }
    N(N &n) { x = n.x; }
    N &operator=(float f) { x = f – 1; return *this; }
    };

    int main() {
    N a;
    a = 2.0;
    cout << a.x;
    return 0;
    }

    • It prints 2
    • It prints 0
    • It prints 1
    • Compilation fails
  17. What happens when you attempt to compile and run the following code?

    #include <iostream>
    #include <string>

    using namespace std;

    class N {
    public:
    float x;
    N() { x = 0.0; }
    N(float a) { x = a; }
    N(N &n) { x = n.x; }
    string operator==(float f) { if(int(x) == int(f)) return “true”; else return “false”; }
    };

    int main() {
    N a(1.1);
    cout << (a == 1.9);
    return 0;
    }

    • It prints true
    • It prints an empty string
    • Compilation fails
    • It prints false
  18. What happens when you attempt to compile and run the following code?

    #include <iostream>

    using namespace std;

    string operator>(float l, float r) { if(int(l) > int(r)) return “true”; else return “false”; }

    int main() {
    float l = 2.0, r=2.9999;
    cout << (l > r);
    return 0;
    }

    • It prints true
    • Compilation fails
    • It prints an empty string
    • It prints false
  19. What happens when you attempt to compile and run the following code?

    #include <iostream>
    #include <string>

    using namespace std;

    class N {
    public:
    float x;
    N() { x = 0.0; }
    N(float a) { x = a; }
    N(N &n) { x = n.x; }
    string operator==(N &n) { if(this != &n) return “true”; else return “false”; }
    };

    int main() {
    N a(1.1), *b = &a;
    cout << (a == *b);
    return 0;
    }

    • It prints true
    • Compilation fails
    • It prints false
    • It prints an empty string
  20. What happens when you attempt to compile and run the following code?

    #include <iostream>
    #include <string>
    using namespace std;
    class X {
    public:
    string n;
    X(string s) : n(s) {}
    void operator() (X x) {
    cout << x.n;
    }
    };
    int main(void) {
    X x(“a”),y(“b”);
    x(y);
    y(x);
    return 0;
    }

    • It prints ba
    • Compilation fails
    • It prints an empty string
    • It prints ab
  • CCNA1 v7
  • CCNA2 v7
  • CCNA3 v7
System Test Exam Answers
Modules 1 – 3 Exam Answers
Modules 4 – 7 Exam Answers
Modules 8 – 10 Exam Answers
Modules 11 – 13 Exam Answers
Modules 14 – 15 Exam Answers
Modules 16 – 17 Exam Answers
Practice Final – ITN Answers
Course Feedback
ITN Practice PT Skills Assessment (PTSA)
Final Exam Answers
Modules 1 – 4 Exam Answers
Modules 5 – 6 Exam Answers
Modules 7 – 9 Exam Answers
Modules 10 – 13 Exam Answers
Modules 14 – 16 Exam Answers
ITN Practice Skills Assessment – PT Answers
SRWE Practice Skills Assessment – PT Part 1 Answers
SRWE Practice Skills Assessment – PT Part 2 Answers
SRWE Hands On Skills Exam Answers
SRWE Practice Final Exam Answers
SRWE Final Exam Answers 
Modules 1 – 2 Exam Answers
Modules 3 – 5 Exam Answers
Modules 6 – 8 Exam Answers
Modules 9 – 12 Exam Answers
Modules 13 – 14 Exam Answers
ITN Practice PT Skills Assessment (PTSA) Answers
SRWE Practice PT Skills Assessment (PTSA) – Part 1 Answers
SRWE Practice PT Skills Assessment (PTSA) – Part 2 Answers
ENSA Practice PT Skills Assessment (PTSA) Answers
ENSA Hands On Skills Exam Answers
Practice Final – ENSA Answers
ENSA Final Exam Answers
CCNA Certification Practice Exam Answers

Copyright © 2023 PressExam.