MC 2016
MC 2016
Examination to be
June 2016
held during the months(s) of
Faculty/ies presenting
Science; Commerce
candidates
Internal examiner(s)
and telephone extension Pravesh Ranchod
number(s)
Course
Time allowance COMS2013 Hours 2
nos
** As Internal Examiner, I certify that this question paper is in final form and is ready
for reproduction.
Name: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Signature: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Instructions
• This is a closed book exam.
• ?? marks = 100%
• The number of marks available for a question is given in square brackets at the
end of the question.
• You may answer the questions in any order, and you may answer all questions.
• Answer the question! Writing an answer that is true but irrelevant to the question
asked will waste your time and receive zero marks.
• If you are not sure about something, put up your hand and wait for an invigila-
tor to come to you.
Page 1 of ??
COMS2013 Mobile Computing June 2016
(d) In Java, you should not use the == operator to compare String objects. Ex-
plain what happens when you do. [3 marks]
(e) What data types would you use to efficiently store the following. State any
assumptions you make:
i. The distance in kilometers between two points, accurate to 1 meter.
[1 marks]
ii. The license plate of a car in Gauteng. [1 marks]
Page 2 of ??
COMS2013 Mobile Computing June 2016
myNames.addName("James");
myNames.printName();
int index=myNames.find("Susan");
}
}
The Names class uses a LinkedList object to store student names. The find
method returns the position of the specified String in the LinkedList. Write
code for the Names class and all necessary methods. [10 marks]
(b) The following questions require you to use standard Java code (not using the
Android APIs).
i. Write a method that takes in an array of integers and returns the average
of these integers as a double. [5 marks]
ii. You are writing a program to handle courses. Each course has an Ar-
rayList containing student numbers stored as Strings. You would like to
know how many students two courses have in common. Write a method
that takes in two ArrayLists and returns an int that represents the number
of items the two ArrayLists have in common. [8 marks]
Page 3 of ??
COMS2013 Mobile Computing June 2016
For example, if a users enters 100, 200 and 300, their bill under the contracts
would be as follows:
• SpeakUp would be R1100 (R300+R200+R600)
• Messager would be R1300 (R400+R600+R300)
• Downloader would be R1800 (R100+R800+R900)
And the program would output “The best contract available to you is SpeakUp”.
[14 marks]
End of question paper
Page 4 of ??