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

MT 103 Assessment Test March 2017

This document is an assessment test for the BSC (HONS) Mobile Technologies program, specifically for the Computer Programming course. It includes instructions for candidates, a total of 100 marks, and a series of questions covering Java programming concepts such as data types, control structures, methods, and class design. The test is scheduled for April 3, 2017, with a duration of 2 hours.

Uploaded by

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

MT 103 Assessment Test March 2017

This document is an assessment test for the BSC (HONS) Mobile Technologies program, specifically for the Computer Programming course. It includes instructions for candidates, a total of 100 marks, and a series of questions covering Java programming concepts such as data types, control structures, methods, and class design. The test is scheduled for April 3, 2017, with a duration of 2 hours.

Uploaded by

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

School of Computing and Information Systems

BSC (HONS) MOBILE TECHNOLOGIES

MT 103 – COMPUTER PROGRAMMING Year 1 Semester2

Assessment Test

Date: 03 April 2017 Time:


09:00hrs
Total Marks: 100 Duration:
2hrs

Instructions to candidates

1. Candidates must attempt all Questions.


2. Candidates attempting to gain unfair advantage or colluding in any way
whatsoever are liable to be disqualified.
3. Do NOT open the question paper until you are told to do so.
4. Candidates are not allowed to bring any material that may be used to copy,
collude or plagiarize the examinations
5. Students are not allowed to write on the question paper.

This question paper consists of Five (5) printed pages excluding the cover page

Page 0 of 6
Question 1
a) List any 6 of the java primitive data types [3 marks]

b) What is variable declaration and how is it different from variable initialization [5 marks]

c) What is the difference between a global and local variable? Give example each
[5 marks]

d) Write a method that will take two integer numbers and return the larger of the two.
[5marks]

e) Declare and initialise an array named num with the values 5, 10, 15, 20. [4 marks]

f) Explain the purpose of methods in a Java program [3 marks]

Total Marks [25]

Page 1 of 6
Question 2
a) Java has three control structures, use examples to describe them (name and give
example for each) [6 marks]

b) Discuss the differences between a prefix and postfix unary operator, give example for
each [6 marks]

c) Why is it necessary to make various classes as opposed to putting everything into different
methods in one class that contains the main method? [4 marks]

d) What is the highest legal index for the following array? [1 mark]

int arrayNum[4];

e) If a class has a private field, which elements would have access to the field? [2 marks]

f) Explain the difference between an object and a class in Java [4 marks]

g) What is the difference between a do-while loop and a while loop? [2 marks]

Total marks [25]

Page 2 of 6
Question 3
a) Give any four (4) rules that must be followed when declaring a java variable. [4 marks]

b) Give any four (4) rules that must be followed when calling a method [4 marks]

c) With an aid of java code example explain the following access modifiers [6 marks]
and discuss how they are used in java:
i. private
ii. public.

d) What is the difference between a void method and a value-returning method [3marks]

e) Study the Java class below and answer the following questions;

1. public class SavingsAccount {


2. private double balance;
3. private double interest;
4. public SavingsAccount() {
5. balance = 0;
6. interest = 0; }
7. public SavingsAccount(double initialBalance, double initialInterest) {
8. balance = initialBalance;
9. interest = initialInterest;
10. }
11. public void deposit(double amount) {
12. balance = balance + amount; }
13. public void withdraw(double amount) {
14. balance = balance - amount; }
15. public void addInterest() {
16. balance = balance + (balance * interest); }
17. public double getBalance() {
18. return balance;
19. }

Page 3 of 6
Given the SavingsAccount class above,
i. Show how you will create an instance of type SavingsAccount with initial balance of
P1000 and interest rate of 10% [2 marks]
ii. Show how you will call/use withdraw method to withdraw 750 from your account
[2 marks]
iii. Show how you will call/use deposit method to deposit P2000 into your account
[2 marks]
iv. Show how you will call/use addInterest method to add interest to your account
[2 marks]

Total marks [25]

Page 4 of 6
Question 4
a) Study the Class diagram below answer the following questions;

+Circle
+Double radius

+Circle()

+Circle(newRadius:
double)

+getArea(): double

i. State the name of the above class [1 mark]

ii. Name the constructors found in this class [2 marks]


iii. From the above class diagram develop a full Java code [ 9 marks]

b) Explain what are (i) static variables, (ii) static methods (iii) static constant
[6 marks]

c) Write a For ….. loop which prints out even numbers only in the range 0 to 20.
[7 marks]

Total marks [25]

End of Exam

Page 5 of 6

You might also like