Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 4 out of 100 pages
Exam (elaborations)

COS1512 Latest Exam pack 2025(Introduction to Programming II)

Document preview thumbnail
Preview 4 out of 100 pages

COS1512 Latest Exam pack 2025(Introduction to Programming II)

Content preview

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

Document information

Uploaded on
August 4, 2025
Number of pages
100
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$2.50

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
kalangulawendy
4.1
(8)
Sold
32
Followers
1
Items
143
Last sold
11 hours ago

Reviews from verified buyers



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions