[go: up one dir, main page]

0% found this document useful (0 votes)
36 views6 pages

MC 2016

This document is an examination paper for the course COMS2013 Mobile Computing at the University of the Witwatersrand, scheduled for June 2016. It includes instructions for candidates, details about the exam format, and a series of questions covering topics such as Java programming and Android development. The paper is structured into sections with specific marks allocated to each question.

Uploaded by

rgg95nmjck
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views6 pages

MC 2016

This document is an examination paper for the course COMS2013 Mobile Computing at the University of the Witwatersrand, scheduled for June 2016. It includes instructions for candidates, details about the exam format, and a series of questions covering topics such as Java programming and Android development. The paper is structured into sections with specific marks allocated to each question.

Uploaded by

rgg95nmjck
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

EXAMS OFFICE

hrs / / USE ONLY


......................................................................................................
University of the Witwatersrand, Johannesburg

Course or topic No(s) COMS2013

Course or topic name(s)


Mobile Computing
Paper Number & title

Examination to be
June 2016
held during the months(s) of

Year of Study 2nd

Degrees/Diplomas for which


BSc, BEconSc
this course is prescribed

Faculty/ies presenting
Science; Commerce
candidates

Internal examiner(s)
and telephone extension Pravesh Ranchod
number(s)

External examiner(s) Prof. S. Gruner

Special materials required None

Course
Time allowance COMS2013 Hours 2
nos

Instructions to candidates See first page of question paper


* As Internal Examiner/Head of Department, I certify that this question paper is in
final form, as approved by the External Examiner, and is ready for reproduction.

** As Internal Examiner, I certify that this question paper is in final form and is ready
for reproduction.

* applicable to formal examinations as approved by an external examiner.


** applicable to formal tests not requiring approval by external examiner.

Delete whichever not applicable.

Name: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Signature: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

(NOT FOR REPRODUCTION)


COMS2013 Mobile Computing June 2016

Instructions
• This is a closed book exam.

• There are 4 pages excluding the cover page.

• There are ?? marks available in total.

• ?? 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

The Java Language [11 marks]


1. (a) Why would you want to make variables or methods private? [2 marks]
(b) What is an abstract method and why are they useful? [2 marks]
(c) In Java, when you modify a String as shown in the code below, Java makes
a new String to contain the result, rather than just adding the item onto the
end of the original String. Why does it do this? [2 marks]
String s="Hello";
s = s + ", Pravesh";

(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]

Android [15 Marks]


2. (a) Explain why network requests on Android must be performed in a back-
ground thread. [4 marks]
(b) What mechanism does Android provide for switching between Activities?
How can you use this to exchange data between Activities? [2 marks]
(c) When communicating with the server, database results need to be encoded
to present them as a string. Name a format which is appropriate for this and
explain why it is useful. [3 marks]
(d) What is the purpose of a layout inflater? [2 marks]
(e) Why is it necessary to provide components with id’s? [2 marks]
(f) Why would you store data in a local SQLite server rather than storing the
data in variables? [2 marks]

Java Programming [20 marks]


3. (a) Assume the following code has been implemented:
public class ManipulateNames{
public static void main(String args[]){
Names myNames = new Names();
myNames.addName("Thato");
myNames.addName("Joe");
myNames.addName("Susan");

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]

Android Programming [14 Marks]


4. Cellphone companies provide various contract options for their customers. Each
contract charges a different amount for data, call minutes and text messages. The
options can be confusing for users, who may struggle to figure out the cheapest
option given their usage patterns. Write a mobile app that takes in the amount
of data, number of call minutes and number of SMS messages the user generally
uses per month and calculates the cheapest contract option for that user.

Page 3 of ??
COMS2013 Mobile Computing June 2016

The contract options available are:


• SpeakUp
– Data - R3 per MB
– Call Minutes - R1 per minute
– SMS - R2 per message
• Messager
– Data - R4 per MB
– Call Minutes - R3 per minute
– SMS - R1 per message
• Downloader
– Data - R1 per MB
– Call Minutes - R4 per minute
– SMS - R3 per message

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 ??

You might also like