Download ASIS.CPP.CertKiller.2019-02-27.228q.vcex

Download Exam

File Info

Exam Certified Protection Professional
Number CPP
File Name ASIS.CPP.CertKiller.2019-02-27.228q.vcex
Size 270 KB
Posted Feb 27, 2019
Download ASIS.CPP.CertKiller.2019-02-27.228q.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 happens when you attempt to compile and run the following code? 
    #include <iostream> 
    #include <set> 
    #include <vector> 
    using namespace std; 
    int main(){ 
        int t[] ={ 3, 4, 2, 1, 6, 5, 7, 9, 8, 0 }; 
        vector<int>v(t, t+10); 
        multiset<int> s1(v.begin(),v.end()); 
        s1.insert(v.begin(),v.end()); 
        pair<multiset<int>::iterator,multiset<int>::iterator> range;
        range = s1.equal_range(6); 
        while (range.first != range.second) { 
       cout<<*range.first<<" "; range.first++; 
        } 
        return 0; 
    }


  1. program outputs: 6 6
  2. program outputs: 5 7
  3. program outputs: 5 5 6 6 7 7
  4. program outputs: 5 5 7 7
  5. program outputs: 1 1 6 6 5 5
Correct answer: A



Question 2

What happens when you attempt to compile and run the following code? 
    #include <vector> 
    #include <iostream> 
    #include <algorithm> 
     
    using namespace std; 
    template<class T>struct Out { 
        ostream  & out; 
        Out(ostream & o): out(o)
        void operator()(const T & val ) { 
        out<<val<<" "; 
        } 
    }; 
    struct Sequence { 
        int start; 
        Sequence(int start):start(start)
        int operator()() { 
        return start++ ;    }}; 
    int main() { 
        vector<int> v1(10); 
        generate(v1.rbegin(), v1.rend(), Sequence(1)); 
        rotate(v1.begin(),v1.begin() + 1, v1.end() ); 
        for_each(v1.begin(), v1.end(), Out<int>(cout) );cout<<endl; 
        return 0; 
    } 
Program outputs:


  1. 1 2 3 4 5 6 7 8 9 10
  2. 10 9 8 7 6 5 4 3 2 1
  3. 9 8 7 6 5 4 3 2 1 10
  4. 1 10 9 8 7 6 5 4 3 2
Correct answer: C



Question 3

What happens when you attempt to compile and run the following code? 
    #include <iostream> 
    #include <fstream> 
    #include <string> 
    #include <list> 
    #include <algorithm> 
    #include <iomanip> 
    using namespace std; 
    class B { int val; 
    public:
        B(int v=0):val(v)
        int getV() const {return val;} 
        operator int() const  { return val; };}; 
     
    template<class T>struct Out { 
        ostream  & out; 
        Out(ostream & o): out(o)
        void operator() (const T & val ) {out<<setw(3)<<hex<<val; } }; 
     
    int main () { 
        int t[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; 
        fstream f("test.out", ios::trunc|ios::out);
        list<B> l(t, t+10); 
        for_each(l.begin(), l.end(), Out<B>(f)); 
        f.close(); 
        f.open("test.out"); 
        for( ; f.good() ; )   { 
        B i; 
        f>>i; 
        cout<<i<<" "; 
        } 
        f.close(); 
        return 0; 
    }


  1. file test.out will be opened writing
  2. file test.out will be truncated
  3. file test.out will be opened for reading
  4. compilation error
  5. program will display sequence 1 2 3 4 5 6 7 8 9 10
Correct answer: D



Question 4

What will happen when you attempt to compile and run the code below, assuming that you enter the following sequence: one two three<enter>?
    #include <iostream> 
    #include <string> 
    using namespace std; 
     
    int main () 
    { 
        string a; 
        cin>>a; 
        cout<<a<<endl; 
        return 0; 
    } 
Program will output:


  1. one
  2. one two three
  3. runtime exception
  4. compilation error
  5. the result is unspecified
Correct answer: A



Question 5

What will happen when you attempt to compile and run the following code? 
    #include <iostream> 
    #include <map> 
    #include <vector> 
    #include <sstream> 
    #include <string> 
    using namespace std; 
    int main() { 
        int t[] = { 3, 4, 2, 1, 0, 3, 4, 1, 2, 0 }; 
        vector<int> v(t, t + 10); 
        multimap<int, string> m; 
        for (vector<int>::iterator i = v.begin(); i != v.end(); i++) {
        stringstream s;s << *i << *i; 
        m.insert(pair<int, string>(*i, s.str())); 
        } 
        pair<multimap<int, string>::iterator, multimap<int, string>::iterator> range;
        range = m.equal_range(2); 
        for (multimap<int, string>::iterator i = range.first; i != range.second; i++) {
        cout << i?>first << " "; 
        } 
        return 0; 
    } 
     
The output will be:


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



Question 6

What happens when you attempt to compile and run the following code? 
    #include <vector> 
    #include <iostream> 
    #include <algorithm> 
    using namespace std; 
    class B { int val; 
    public:
        B(int v):val(v)
        int getV() const {return val;}  bool operator < (const B & v) const { return val>v.val;} }; 
    ostream & operator <<(ostream & out, const B & v) { out<<v.getV(); return out;} 
    template<class T>struct Out { 
        ostream  & out; 
        Out(ostream & o): out(o)
        void operator() (const T & val ) { out<<val<<" "; } }; 
     
    int main() { 
        B t1[]={3,2,4,1,5}; 
        B t2[]={5,6,8,2,1}; 
        vector<B> v1(10,0); 
        sort(t1, t1+5); 
        sort(t2, t2+5); 
        set_intersection(t1,t1+5,t2,t2+5,v1.begin()); 
        for_each(v1.begin(), v1.end(), Out<B>(cout));cout<<endl; 
        return 0; 
    } 
Program outputs:


  1. compilation error
  2. 1 2 3 4 5 6 8 0 0 0
  3. 1 2 3 4 5 6 8 2 1 0
  4. 5 2 1 0 0 0 0 0 0 0
  5. 1 2 5 0 0 0 0 0 0 0
Correct answer: D



Question 7

What happens when you attempt to compile and run the following code? 
    #include <list> 
    #include <vector> 
    #include <iostream> 
    using namespace std; 
    int main () 
    { 
        int t[] = {1, 2 ,3 ,4 ,5}; 
        vector<int>v1(t, t+5); 
        list<int>l1; 
        l1.assign(v1.end(), v1.begin()); 
        for(int i=0; i<l1.size(); i++) 
        { 
        cout<<l1.at(i)<<" "; 
        } 
        cout<<endl; 
        return 0; 
    }


  1. program displays 5 4 3 2 1
  2. program displays 1 2 3 4 5
  3. compilation error
  4. segmentation fault runtime exception
Correct answer: C



Question 8

What happens when you attempt to compile and run the following code? 
    #include <vector> 
    #include <iostream> 
    #include <algorithm> 
    using namespace std; 
    class B { int val; 
    public:
        B(int v):val(v)
        int getV() const {return val;}  bool operator < (const B & v) const { return val<v.val;} }; 
    ostream & operator <<(ostream & out, const B & v) { out<<v.getV(); return out;} 
     
    template<class T>struct Out { 
        ostream  & out; 
        Out(ostream & o): out(o)
        void operator() (const T & val ) { out<<val<<" "; } }; 
     
    int main() { 
        B t1[]={3,2,4,1,5}; 
        B t2[]={6,10,8,7,9}; 
        vector<B> v1(10); 
        sort(t1, t1+5); 
        sort(t2, t2+5); 
        merge(t1,t1+5,t2,t2+5,v1.begin()); 
        for_each(v1.begin(), v1.end(), Out<B>(cout));cout<<endl; 
        return 0; 
    } 
Program outputs:


  1. 1 2 3 4 5 6 10 8 7 9
  2. 3 2 4 1 5 6 7 8 9 10
  3. 3 2 4 1 5 6 10 8 7 9
  4. 1 2 3 4 5 6 7 8 9 10
  5. compilation error
Correct answer: E



Question 9

Which sentence is correct about the code below? 
    #include <iostream> 
    #include <algorithm> 
    #include <vector> 
    using namespace std; 
    class A { 
        int a; 
    public:
        A(int a) :    a(a) 
        int getA() const { return a; } 
        void setA(int a) { this?>a = a; } 
        /* Insert Code Here */ 
    }; 
     
    struct add10 { void operator()(A & a) { a.setA(a.getA() + 10); } }; 
     
    int main() { 
        int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 }; 
        vector<A> v1(t, t + 10); 
        for_each(v1.begin(), v1.end(), add10()); 
        vector<A>::iterator it = find(v1.begin(), v1.end(), A(7));
        cout << it?>getA() << endl; 
        return 0; 
    }


  1. it will compile and print 7
  2. it will not compile
  3. it will compile but the program result is unpredictable
  4. adding code: 
        bool operator !=(const A & b) const { 
        if (this?>a != b.a) { return true; } return false; } 
    at Place 1 will allow the program to compile
Correct answer: B



Question 10

What happens when you attempt to compile and run the following code? 
    #include <iostream> 
    #include <algorithm> 
    #include <vector> 
    using namespace std; 
     
    void myfunction(int i) { 
        cout << " " << i; 
    } 
    void multiply (int a) { 
        a*2; 
    } 
     
    int main() { 
        int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 }; 
        vector<int> v1(t, t+10); 
        for_each(v1.begin(), v1.end(), multiply); 
        iter_swap(v1.begin(),t+9); 
        for_each(v1.begin(), v1.end(), myfunction); 
        return 0; 
    } 
Program outputs:


  1. 1 5 9 6 2 4 7 8 3 1
  2. compilation error
  3. 1 2 3 4 5 6 7 8 9 10
  4. 10 9 8 7 6 5 4 3 2 1
  5. 10 5 9 6 2 4 7 8 3 1
Correct answer: A



Question 11

What happens when you attempt to compile and run the following code? 
    #include <iostream> 
    #include <set> 
    #include <vector> 
    using namespace std; 
    int main(){ 
        int t[] ={ 3, 4, 2, 1, 6, 5, 7, 9, 8, 0 }; 
        vector<int>v(t, t+10); 
        multiset<int> s1(v.begin(),v.end()); 
        s1.insert(v.begin(),v.end()); 
        pair<multiset<int>::iterator,multiset<int>::iterator> range;
        range = s1.equal_range(6); 
        while (range.first != range.second) { 
       cout<<*range.first<<" "; range.first++; 
        } 
        return 0; 
    }


  1. program outputs: 6 6
  2. program outputs: 5 7
  3. program outputs: 5 5 6 6 7 7
  4. program outputs: 5 5 7 7
  5. program outputs: 1 1 6 6 5 5
Correct answer: A



Question 12

What happens when you attempt to compile and run the following code? 
    #include <vector> 
    #include <iostream> 
    #include <algorithm> 
     
    using namespace std; 
    template<class T>struct Out { 
        ostream  & out; 
        Out(ostream & o): out(o)
        void operator()(const T & val ) { 
        out<<val<<" "; 
        } 
    }; 
    struct Sequence { 
        int start; 
        Sequence(int start):start(start)
        int operator()() { 
        return start++ ;    }}; 
    int main() { 
        vector<int> v1(10); 
        generate(v1.rbegin(), v1.rend(), Sequence(1)); 
        rotate(v1.begin(),v1.begin() + 1, v1.end() ); 
        for_each(v1.begin(), v1.end(), Out<int>(cout) );cout<<endl; 
        return 0; 
    } 
Program outputs:


  1. 1 2 3 4 5 6 7 8 9 10
  2. 10 9 8 7 6 5 4 3 2 1
  3. 9 8 7 6 5 4 3 2 1 10
  4. 1 10 9 8 7 6 5 4 3 2
Correct answer: C



Question 13

What happens when you attempt to compile and run the following code? 
    #include <iostream> 
    #include <fstream> 
    #include <string> 
    #include <list> 
    #include <algorithm> 
    #include <iomanip> 
    using namespace std; 
    class B { int val; 
    public:
        B(int v=0):val(v)
        int getV() const {return val;} 
        operator int() const  { return val; };}; 
     
    template<class T>struct Out { 
        ostream  & out; 
        Out(ostream & o): out(o)
        void operator() (const T & val ) {out<<setw(3)<<hex<<val; } }; 
     
    int main () { 
        int t[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; 
        fstream f("test.out", ios::trunc|ios::out);
        list<B> l(t, t+10); 
        for_each(l.begin(), l.end(), Out<B>(f)); 
        f.close(); 
        f.open("test.out"); 
        for( ; f.good() ; )   { 
        B i; 
        f>>i; 
        cout<<i<<" "; 
        } 
        f.close(); 
        return 0; 
    }


  1. file test.out will be opened writing
  2. file test.out will be truncated
  3. file test.out will be opened for reading
  4. compilation error
  5. program will display sequence 1 2 3 4 5 6 7 8 9 10
Correct answer: D



Question 14

What will happen when you attempt to compile and run the code below, assuming that you enter the following sequence: one two three<enter>?
    #include <iostream> 
    #include <string> 
    using namespace std; 
     
    int main () 
    { 
        string a; 
        cin>>a; 
        cout<<a<<endl; 
        return 0; 
    } 
Program will output:


  1. one
  2. one two three
  3. runtime exception
  4. compilation error
  5. the result is unspecified
Correct answer: A



Question 15

What will happen when you attempt to compile and run the following code? 
    #include <iostream> 
    #include <map> 
    #include <vector> 
    #include <sstream> 
    #include <string> 
    using namespace std; 
    int main() { 
        int t[] = { 3, 4, 2, 1, 0, 3, 4, 1, 2, 0 }; 
        vector<int> v(t, t + 10); 
        multimap<int, string> m; 
        for (vector<int>::iterator i = v.begin(); i != v.end(); i++) {
        stringstream s;s << *i << *i; 
        m.insert(pair<int, string>(*i, s.str())); 
        } 
        pair<multimap<int, string>::iterator, multimap<int, string>::iterator> range;
        range = m.equal_range(2); 
        for (multimap<int, string>::iterator i = range.first; i != range.second; i++) {
        cout << i?>first << " "; 
        } 
        return 0; 
    } 
     
The output will be:


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



Question 16

What happens when you attempt to compile and run the following code? 
    #include <vector> 
    #include <iostream> 
    #include <algorithm> 
    using namespace std; 
    class B { int val; 
    public:
        B(int v):val(v)
        int getV() const {return val;}  bool operator < (const B & v) const { return val>v.val;} }; 
    ostream & operator <<(ostream & out, const B & v) { out<<v.getV(); return out;} 
    template<class T>struct Out { 
        ostream  & out; 
        Out(ostream & o): out(o)
        void operator() (const T & val ) { out<<val<<" "; } }; 
     
    int main() { 
        B t1[]={3,2,4,1,5}; 
        B t2[]={5,6,8,2,1}; 
        vector<B> v1(10,0); 
        sort(t1, t1+5); 
        sort(t2, t2+5); 
        set_intersection(t1,t1+5,t2,t2+5,v1.begin()); 
        for_each(v1.begin(), v1.end(), Out<B>(cout));cout<<endl; 
        return 0; 
    } 
Program outputs:


  1. compilation error
  2. 1 2 3 4 5 6 8 0 0 0
  3. 1 2 3 4 5 6 8 2 1 0
  4. 5 2 1 0 0 0 0 0 0 0
  5. 1 2 5 0 0 0 0 0 0 0
Correct answer: D



Question 17

What happens when you attempt to compile and run the following code? 
    #include <list> 
    #include <vector> 
    #include <iostream> 
    using namespace std; 
    int main () 
    { 
        int t[] = {1, 2 ,3 ,4 ,5}; 
        vector<int>v1(t, t+5); 
        list<int>l1; 
        l1.assign(v1.end(), v1.begin()); 
        for(int i=0; i<l1.size(); i++) 
        { 
        cout<<l1.at(i)<<" "; 
        } 
        cout<<endl; 
        return 0; 
    }


  1. program displays 5 4 3 2 1
  2. program displays 1 2 3 4 5
  3. compilation error
  4. segmentation fault runtime exception
Correct answer: C



Question 18

What happens when you attempt to compile and run the following code? 
    #include <vector> 
    #include <iostream> 
    #include <algorithm> 
    using namespace std; 
    class B { int val; 
    public:
        B(int v):val(v)
        int getV() const {return val;}  bool operator < (const B & v) const { return val<v.val;} }; 
    ostream & operator <<(ostream & out, const B & v) { out<<v.getV(); return out;} 
     
    template<class T>struct Out { 
        ostream  & out; 
        Out(ostream & o): out(o)
        void operator() (const T & val ) { out<<val<<" "; } }; 
     
    int main() { 
        B t1[]={3,2,4,1,5}; 
        B t2[]={6,10,8,7,9}; 
        vector<B> v1(10); 
        sort(t1, t1+5); 
        sort(t2, t2+5); 
        merge(t1,t1+5,t2,t2+5,v1.begin()); 
        for_each(v1.begin(), v1.end(), Out<B>(cout));cout<<endl; 
        return 0; 
    } 
Program outputs:


  1. 1 2 3 4 5 6 10 8 7 9
  2. 3 2 4 1 5 6 7 8 9 10
  3. 3 2 4 1 5 6 10 8 7 9
  4. 1 2 3 4 5 6 7 8 9 10
  5. compilation error
Correct answer: E



Question 19

Which sentence is correct about the code below? 
    #include <iostream> 
    #include <algorithm> 
    #include <vector> 
    using namespace std; 
    class A { 
        int a; 
    public:
        A(int a) :    a(a) 
        int getA() const { return a; } 
        void setA(int a) { this?>a = a; } 
        /* Insert Code Here */ 
    }; 
     
    struct add10 { void operator()(A & a) { a.setA(a.getA() + 10); } }; 
     
    int main() { 
        int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 }; 
        vector<A> v1(t, t + 10); 
        for_each(v1.begin(), v1.end(), add10()); 
        vector<A>::iterator it = find(v1.begin(), v1.end(), A(7));
        cout << it?>getA() << endl; 
        return 0; 
    }


  1. it will compile and print 7
  2. it will not compile
  3. it will compile but the program result is unpredictable
  4. adding code: 
        bool operator !=(const A & b) const { 
        if (this?>a != b.a) { return true; } return false; } 
    at Place 1 will allow the program to compile
Correct answer: B



Question 20

What happens when you attempt to compile and run the following code? 
    #include <iostream> 
    #include <algorithm> 
    #include <vector> 
    using namespace std; 
     
    void myfunction(int i) { 
        cout << " " << i; 
    } 
    void multiply (int a) { 
        a*2; 
    } 
     
    int main() { 
        int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 }; 
        vector<int> v1(t, t+10); 
        for_each(v1.begin(), v1.end(), multiply); 
        iter_swap(v1.begin(),t+9); 
        for_each(v1.begin(), v1.end(), myfunction); 
        return 0; 
    } 
Program outputs:


  1. 1 5 9 6 2 4 7 8 3 1
  2. compilation error
  3. 1 2 3 4 5 6 7 8 9 10
  4. 10 9 8 7 6 5 4 3 2 1
  5. 10 5 9 6 2 4 7 8 3 1
Correct answer: A









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