COS1512 LATEST
EXAM PACK 2025
QUESTIONS AND
ANSWERS
FOR ASSISTANCE CONTACT
EMAIL:
, lOMoARcPSD|31863004
11/11/2022, 13:08 COS1512-Exam Oct/Nov 2022: Attempt review
MENU
Started on Friday, 11 November 2022, 9:57 AM
State Finished
Completed on Friday, 11 November 2022, 11 :57 AM
Time taken 2 hours
Question 1
Complete
Marked out of 1.00
Given the code
vector<int> numbers(20);
what is the result of executing the following statement?
numbers.resize(lO);
Select one:
This causes a run-time error
The last 10 elements are removed
No change
The first 10 elements are removed
https-J/cset.myexams.unisa.ac.za/mod/quiz/review.php?attem pt= 164372&cmid=72548 1/22
, lOMoARcPSD|31863004
11/11/2022, 13:08 COS1512-Exam OcUNov 2022: Attempt review
"1 2
V te
Marked out of 4.00
MENU _
Consider the following partial class declaration ot an ADT:
class Player
friend istream & operator>> (istream & ins, Player & P);
publi c :
Player();
Player(string nam, int point);
i nt getPoints() co nst;
void set Name(string n);
void increment(int nrPoints);
private:
st ring nam e ;
int poi nts;
};
Complete the code below by choosing the correct options in the drop-down lists.
Player aPlayer('' ", 0); //Ins tantiate an objec t aPlayer of the class Pla yer using the default constructor
cin > > a Player; //Use the o v e rloaded stream extraction operat or to read a va lu e for
t h e ob ject aP l a y er fro m t h e keyb oar d
if (aPlayer.getPoints() < 100) // Tes t i f a Pl aye r' s po i nt s i s l ess t h a n 1 00,
aPlayer.points = aPlayer . points + 20 ; / / If the points is less than 100, increment it by 20 .
https://cset.myexams.unisa.ac. za/mod/quiz/review.php?attempt=164372&cmid=72548 2/22
, lOMoARcPSD|31863004
11/11/2022, 13:08 COS1512-Exam OcUNov 2022: Attempt review
"1 3
V te
Marked out of 1.00
MENU _
\.JIVCll LllC LVVU IUll\.LIUll UCl..lc:lldLIUll;') IUI IUIH .. LIUll .LU!H .; , LllCH UUC:> Liit: ::>CillllC CJ\\..C:tJL LllCH UllC VCl::>IUll C'AIJCl..L;) LVVU lllLcyc1 tJdlcUllCLCI;), ClllU LllC
other expects a float and an integer parameter
void func(int a, int b)
void fun c ( i nt a, f l oat b )
Which parameters would you change to a Tin order to make this a template function?
Select one:
Neither parameters change.
Both parameters change.
The parameter that is an integer in one function and a f l oa t in the other function.
The parameter that always stays an integer.
Question 4
Complete
Marked out of 1.00
In the derived class definition, you list from the base class
Select one:
only those member functions that need to be redefined.
all the member functions every time.
only those member functions you want to overload.
only those member functions that were in the public section.
3/22
EXAM PACK 2025
QUESTIONS AND
ANSWERS
FOR ASSISTANCE CONTACT
EMAIL:
, lOMoARcPSD|31863004
11/11/2022, 13:08 COS1512-Exam Oct/Nov 2022: Attempt review
MENU
Started on Friday, 11 November 2022, 9:57 AM
State Finished
Completed on Friday, 11 November 2022, 11 :57 AM
Time taken 2 hours
Question 1
Complete
Marked out of 1.00
Given the code
vector<int> numbers(20);
what is the result of executing the following statement?
numbers.resize(lO);
Select one:
This causes a run-time error
The last 10 elements are removed
No change
The first 10 elements are removed
https-J/cset.myexams.unisa.ac.za/mod/quiz/review.php?attem pt= 164372&cmid=72548 1/22
, lOMoARcPSD|31863004
11/11/2022, 13:08 COS1512-Exam OcUNov 2022: Attempt review
"1 2
V te
Marked out of 4.00
MENU _
Consider the following partial class declaration ot an ADT:
class Player
friend istream & operator>> (istream & ins, Player & P);
publi c :
Player();
Player(string nam, int point);
i nt getPoints() co nst;
void set Name(string n);
void increment(int nrPoints);
private:
st ring nam e ;
int poi nts;
};
Complete the code below by choosing the correct options in the drop-down lists.
Player aPlayer('' ", 0); //Ins tantiate an objec t aPlayer of the class Pla yer using the default constructor
cin > > a Player; //Use the o v e rloaded stream extraction operat or to read a va lu e for
t h e ob ject aP l a y er fro m t h e keyb oar d
if (aPlayer.getPoints() < 100) // Tes t i f a Pl aye r' s po i nt s i s l ess t h a n 1 00,
aPlayer.points = aPlayer . points + 20 ; / / If the points is less than 100, increment it by 20 .
https://cset.myexams.unisa.ac. za/mod/quiz/review.php?attempt=164372&cmid=72548 2/22
, lOMoARcPSD|31863004
11/11/2022, 13:08 COS1512-Exam OcUNov 2022: Attempt review
"1 3
V te
Marked out of 1.00
MENU _
\.JIVCll LllC LVVU IUll\.LIUll UCl..lc:lldLIUll;') IUI IUIH .. LIUll .LU!H .; , LllCH UUC:> Liit: ::>CillllC CJ\\..C:tJL LllCH UllC VCl::>IUll C'AIJCl..L;) LVVU lllLcyc1 tJdlcUllCLCI;), ClllU LllC
other expects a float and an integer parameter
void func(int a, int b)
void fun c ( i nt a, f l oat b )
Which parameters would you change to a Tin order to make this a template function?
Select one:
Neither parameters change.
Both parameters change.
The parameter that is an integer in one function and a f l oa t in the other function.
The parameter that always stays an integer.
Question 4
Complete
Marked out of 1.00
In the derived class definition, you list from the base class
Select one:
only those member functions that need to be redefined.
all the member functions every time.
only those member functions you want to overload.
only those member functions that were in the public section.
3/22