Exclusive Black Friday Deal: 70% Off All Exam Bundles! Use coupon code below to unlock your savings! - Ends in 0d 00h 00m 00s - Coupon code: Friday70

Free Beingcert Certified Python Programmer Exam Practice Questions

Question # 11

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

#include

#include

#include

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

};

int main () {

int t[] = {1,2,3,2,3,5,1,2,7,3,2,1,10, 4,4,5};

deque d (t,t+15);

int number = count(d.begin(), d.end(), 2);

cout<< number<

return 0;

}

Program outputs:

Options:

A.  

4

B.  

3

C.  

2

D.  

0

E.  

compilation error

Discussion 0
Question # 12

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

#include

#include

using namespace std;

int main() {

int t[] = { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 };

string s[] = { "one", "one", "two", "two", "three","three", "four", "four", "five", "five"};

map m;

for (int i = 0; i < 10; i++) {

m.push_back(pair(t[i], s[i]));

}

for (map::iterator i = m.begin(); i != m.end(); i++) {

cout << i?>first << " ";

}

return 0;

}

Options:

A.  

program outputs: 1 2 3 4 5

B.  

compilation error

C.  

program outputs: 1 1 2 2 3 3 4 4 5 5

D.  

program outputs: one two three four five

E.  

program outputs: one one two two three three four four five five

Discussion 0
Question # 13

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

#include

#include

#include

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

ostream & operator <<(ostream & out, const B & v) { out<

templatestruct Out {

ostream & out;

Out(ostream & o): out(o){}

void operator() (const T & val ) { out<

int main() {

B t1[]={3,2,4,1,5};

B t2[]={6,10,8,7,9};

vector 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(cout));cout<

return 0;

}

Program outputs:

Options:

A.  

1 2 3 4 5 6 10 8 7 9

B.  

3 2 4 1 5 6 7 8 9 10

C.  

3 2 4 1 5 6 10 8 7 9

D.  

1 2 3 4 5 6 7 8 9 10

E.  

compilation error

Discussion 0
Question # 14

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

#include

#include

#include

#include

#include

#include

using namespace std;

class B { int val;

public:

B(int v=0):val(v){}

int getV() const {return val;}

operator int() const { return val; };};

templatestruct Out {

ostream & out;

Out(ostream & o): out(o){}

void operator() (const T & val ) {out<

int main () {

int t[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

fstream f("test.out", ios::trunc|ios::out);

list l(t, t+10);

for_each(l.begin(), l.end(), Out(f));

f.close();

f.open("test.out");

for( ; f.good() ; ) {

B i;

f>>i;

cout<

}

f.close();

return 0;

}

Options:

A.  

file test.out will be opened writing

B.  

file test.out will be truncated

C.  

file test.out will be opened for reading

D.  

compilation error

E.  

program will display sequence 1 2 3 4 5 6 7 8 9 10

Discussion 0
Question # 15

Which stack initialization (line numbers) are correct? Choose all that apply.

#include

#include

#include

#include

#include

using namespace std;

int main()

{

deque mydeck;

list mylist;

vector myvector;

stack first;// Line I

stack second(mydeck);// Line II

stack third(second);// Line III

stack > fourth(mylist);// Line IV

stack > fifth(myvector);// Line V

return 0;

}

Options:

A.  

line I

B.  

line II

C.  

line III

D.  

line IV

E.  

line V

Discussion 0
Question # 16

Which method added to class B at the marked spot will allow the code below to compile? Choose all possible solutions.

#include

#include

#include

using namespace std;

class B { int val;

public:

B(int v):val(v){}

int getV() const {return val;}

/* Insert Code Here */

};

ostream & operator <<(ostream & out, const B & v) { out<

templatestruct Out {

ostream & out;

Out(ostream & o): out(o){}

void operator() (const T & val ) { out<

int main() {

int t[]={8, 10, 5, 1, 4, 6, 2, 7, 9, 3};

vector v1(t, t+10);

sort(v1.begin(), v1.end(), greater());

for_each(v1.begin(), v1.end(), Out(cout));cout<

return 0;

}

Options:

A.  

bool operator < (const B & v) const { return val

B.  

bool operator > (const B & v) const { return val

C.  

bool operator > (const B & v) const { return val>v.val;}

D.  

bool operator == (const B & v) const { return val==v.val;}

E.  

operator int () const { return val; }

Discussion 0
Question # 17

What happens when you attempt to compile and run the following code? Choose all that apply.

#include

#include

#include

#include

#include

#include

using namespace std;

templatestruct Out {

ostream & out;

Out(ostream & o): out(o){}

void operator() (const T & val ) {out<

int main () {

int t[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

fstream f("test.out", ios::trunc|ios::out);

list l(t, t+10);

for_each(l.begin(), l.end(), Out(f));

f.close(); f.open("test.out");

for( ; f.good() ; ) {

int i; f>>i;

cout<

}

f.close();

return 0;

}

Options:

A.  

file test.out will be opened writing

B.  

file test.out will be truncated

C.  

file test.out will be opened for reading

D.  

no file will be created nor opened

E.  

program will display sequence 1 2 3 4 5 6 7 8 9 10

Discussion 0
Question # 18

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

#include

#include

#include

#include

using namespace std;

void myfunction(int i) {

cout << " " << i;

}

int main() {

int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 };

set s1(t, t+10);

vector v1(s1.rbegin(), s1.rend());

swap(s1, v1);

for_each(v1.begin(), v1.end(), myfunction);

for_each(s1.begin(), s1.end(), myfunction);

return 0;

}

Program outputs:

Options:

A.  

10 9 8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 9 10

B.  

compilation error

C.  

1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10

D.  

10 9 8 7 6 5 4 3 2 1 10 9 8 7 6 5 4 3 2 1

Discussion 0
Question # 19

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

#include

#include

#include

#include

#include

using namespace std;

int main()

{

deque mydeck;list mylist; vector myvector;

queue first; queue second(mydeck);

queue third(second); queue > fourth(mylist);

fourth.push(10);fourth.push(11);fourth.push(12);

queue > fifth(myvector);

fifth.push(10);fifth.push(11);fifth.push(12); // Line I

while(!fifth.empty())

{

cout<

fifth.pop(); // Line III

}

while (!fourth.empty())

{

cout << fourth.front() << " ";

fourth.pop(); // Line IV

}

return 0;

}

Options:

A.  

program outputs: 10 11 12 10 11 12

B.  

compilation error in line I

C.  

compilation error in line II

D.  

compilation error in line III

E.  

compilation error in line IV

Discussion 0
Question # 20

What happens when you attempt to compile and run the following code? Choose all that apply.

#include

#include

using namespace std;

int main ()

{

vectorv1(10, 3);

v1.push_back(3);

cout<

return 0;

}

Options:

A.  

program displays 4 4

B.  

program displays 10 3

C.  

size of vector v1 is 11

D.  

all elements of vector v1 are of the same value

Discussion 0

CPP PDF

CPP PDF (Printable)
$180
$600

CPP Testing Engine

CPP PDF (Printable)
$180
$600

CPP PDF + Testing Engine

CPP PDF (Printable)

Free Exams Sample Questions

  • We Accept

    exams4sure payments accept


    Secure Site

    mcafee secure

    TESTED 20 Nov 2026

  • Customer Review

    I was overwhelmed by the amount of material I had to cover, but Exams4sure's practice questions were incredibly close to the real exam. I studied for three weeks and passed with confidence. Highly recommend it to anyone short on time!

    exams4sure customer reviews
    Ivy Rose Happy Customer
  • Quality Commitment

    We don't just sell practice tests, we deliver results. Our material is carefully crafted to cover exactly what you need, so even with a tight schedule, you can prepare effectively and pass with confidence. If it doesn't meet your expectations, we're only a message away, your success and satisfaction come first.