Download C++ Institute.CPA.RealExams.2019-02-28.220q.vcex

Download Exam

File Info

Exam C++ Certified Associate Programmer
Number CPA
File Name C++ Institute.CPA.RealExams.2019-02-28.220q.vcex
Size 186 KB
Posted Feb 28, 2019
Download C++ Institute.CPA.RealExams.2019-02-28.220q.vcex

How to open VCEX & EXAM Files?

Files with VCEX & EXAM extensions can be opened by ProfExam Simulator.

Purchase

Coupon: MASTEREXAM
With discount: 20%






Demo Questions

Question 1

What will the variable "age" be in class B? 
    class A { 
            int x; 
    protected:
            int y; 
    public:
            int age; 
            A () { age=5; }; 
    };     
     
    class B : public A {
            string name; 
    public:
            B () { name="Bob"; }; 
            void Print() { 
                cout << name << age; 
            } 
    };


  1. public
  2. private
  3. protected
  4. None of these
Correct answer: A



Question 2

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(); 
    }


  1. It prints: 1 0.4
  2. It prints: 2 0.8
  3. It prints: 0 0
  4. It prints: 1 0.8
Correct answer: C



Question 3

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; 
            }


  1. It prints: 0 0
  2. It prints: 1 1
  3. It prints: 3 3
  4. Compilation error
Correct answer: C



Question 4

What happens when you attempt to compile and run the following code? 
    #include <iostream>     
     
    using namespace std;     
     
    void fun(int);     
     
    int main() 
    { 
            int a=0; 
            fun(a); 
            return 0; 
    } 
     
     
    void fun(int n) 
    { 
            if(n < 2) 
            { 
                fun(++n); 
                cout << n; 
            } 
    }


  1. It prints: 21
  2. It prints: 012
  3. It prints: 0
  4. None of these
Correct answer: A



Question 5

What happens when you attempt to compile and run the following code? 
    #include <iostream> 
    using namespace std;     
     
    int s(int n); 
         
    int main() 
    { 
            int a; 
            a = 3; 
            cout << s(a); 
            return 0; 
    } 
     
     
    int s(int n) 
    { 
            if(n == 0) return 1; 
            return s(n?1)*n; 
    }


  1. It prints: 4
  2. It prints: 6
  3. It prints: 3
  4. It prints: 0
Correct answer: B



Question 6

What will be the output of the program? 
    #include <iostream>     
     
    using namespace std;     
     
    int fun(int);     
     
    int main() 
    { 
            cout << fun(5); 
            return 0; 
    } 
     
     
    int fun(int i) 
    { 
            return i*i; 
    }


  1. 25
  2. 5
  3. 0
  4. 1
Correct answer: A



Question 7

What happens when you attempt to compile and run the following code? 
    #include <iostream>     
     
    using namespace std;     
     
    #define FUN(arg) if(arg) cout<<"Test";     
     
    int main() 
    { 
        int i=1; 
        FUN(i<3); 
        return 0; 
    }


  1. It prints: 0
  2. It prints: T
  3. It prints: T0
  4. It prints: Test
Correct answer: D



Question 8

What will the variable "y" be in class B? 
    class A { 
            int x; 
    protected:
            int y; 
    public:
            int age; 
    }; 
     
     
    class B: private A {
            string name; 
    public:
            void Print() { 
                cout << name << age; 
            } 
    };


  1. public
  2. private
  3. protected
  4. None of these
Correct answer: B



Question 9

What happens when you attempt to compile and run the following code? 
    #include <iostream>     
     
    using namespace std;     
     
    int main() 
    { 
      float x=3.5,y=1.6; 
      int i,j=2; 
      i = x + j + y; 
      cout << i; 
      return 0; 
    }


  1. It prints: 7
  2. It prints: 6
  3. It prints: 7,1
  4. Compilation error
Correct answer: A



Question 10

What 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-1; 
               } 
               return 0; 
            }


  1. It prints: 0
  2. It prints: 1
  3. It prints: -1
  4. It prints: 2
Correct answer: B



Question 11

What will the variable "age" be in class B? 
    class A { 
            int x; 
    protected:
            int y; 
    public:
            int age; 
            A () { age=5; }; 
    };     
     
    class B : public A {
            string name; 
    public:
            B () { name="Bob"; }; 
            void Print() { 
                cout << name << age; 
            } 
    };


  1. public
  2. private
  3. protected
  4. None of these
Correct answer: A



Question 12

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(); 
    }


  1. It prints: 1 0.4
  2. It prints: 2 0.8
  3. It prints: 0 0
  4. It prints: 1 0.8
Correct answer: C



Question 13

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; 
            }


  1. It prints: 0 0
  2. It prints: 1 1
  3. It prints: 3 3
  4. Compilation error
Correct answer: C



Question 14

What happens when you attempt to compile and run the following code? 
    #include <iostream>     
     
    using namespace std;     
     
    void fun(int);     
     
    int main() 
    { 
            int a=0; 
            fun(a); 
            return 0; 
    } 
     
     
    void fun(int n) 
    { 
            if(n < 2) 
            { 
                fun(++n); 
                cout << n; 
            } 
    }


  1. It prints: 21
  2. It prints: 012
  3. It prints: 0
  4. None of these
Correct answer: A



Question 15

What happens when you attempt to compile and run the following code? 
    #include <iostream> 
    using namespace std;     
     
    int s(int n); 
         
    int main() 
    { 
            int a; 
            a = 3; 
            cout << s(a); 
            return 0; 
    } 
     
     
    int s(int n) 
    { 
            if(n == 0) return 1; 
            return s(n?1)*n; 
    }


  1. It prints: 4
  2. It prints: 6
  3. It prints: 3
  4. It prints: 0
Correct answer: B



Question 16

What will be the output of the program? 
    #include <iostream>     
     
    using namespace std;     
     
    int fun(int);     
     
    int main() 
    { 
            cout << fun(5); 
            return 0; 
    } 
     
     
    int fun(int i) 
    { 
            return i*i; 
    }


  1. 25
  2. 5
  3. 0
  4. 1
Correct answer: A



Question 17

What happens when you attempt to compile and run the following code? 
    #include <iostream>     
     
    using namespace std;     
     
    #define FUN(arg) if(arg) cout<<"Test";     
     
    int main() 
    { 
        int i=1; 
        FUN(i<3); 
        return 0; 
    }


  1. It prints: 0
  2. It prints: T
  3. It prints: T0
  4. It prints: Test
Correct answer: D



Question 18

What will the variable "y" be in class B? 
    class A { 
            int x; 
    protected:
            int y; 
    public:
            int age; 
    }; 
     
     
    class B: private A {
            string name; 
    public:
            void Print() { 
                cout << name << age; 
            } 
    };


  1. public
  2. private
  3. protected
  4. None of these
Correct answer: B



Question 19

What happens when you attempt to compile and run the following code? 
    #include <iostream>     
     
    using namespace std;     
     
    int main() 
    { 
      float x=3.5,y=1.6; 
      int i,j=2; 
      i = x + j + y; 
      cout << i; 
      return 0; 
    }


  1. It prints: 7
  2. It prints: 6
  3. It prints: 7,1
  4. Compilation error
Correct answer: A



Question 20

What 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-1; 
               } 
               return 0; 
            }


  1. It prints: 0
  2. It prints: 1
  3. It prints: -1
  4. It prints: 2
Correct answer: B









CONNECT US

Facebook

Twitter

PROFEXAM WITH A 20% DISCOUNT

You can buy ProfExam with a 20% discount!



HOW TO OPEN VCEX FILES

Use ProfExam Simulator to open VCEX files