Programming Fundamentals SAMPLE Final Exam
Programming Fundamentals SAMPLE Final Exam
FINAL EXAMINATION
SAMPLE – September 2017
IPRG001 / EPRG001
Number of Questions: 20
N.B. A page for completing notes during the exam is attached to the end of this exam paper. This page
must not be removed from the exam room.
INSEARCH
CRICOS Provider Code: 00859D
PROGRAMMING FUNDAMENTALS SAMPLE FINAL EXAMINATION
You must not try to get any help in these examinations or give help to any other
student.
You must not bring any unauthorised information or materials into the examination
room, toilets or in any other place visited by you during the examination.
Mobile phones must be switched off and placed under your chair for the duration
of the exam.
You must NOT have any writing on your body or write notes on your body during
the exam.
You must not make notes on any materials other than those provided.
Any items brought into the examination room must be available for inspection and
must be placed where directed by the supervisor.
Programmable calculators are not permitted and your calculator must not have a
cover, nor have anything written on it or any notes enclosed in it.
The examination paper and the answer sheets/booklets must not be removed from
the examination room. You are to remain seated until all examination papers and
answer sheets/booklets are collected.
You are not permitted to leave the examination room for any reason until 90
minutes of writing time has passed or within 15 minutes of the examination
concluding.
Any student who breaks the examination rules, is found cheating, behaves in a
disorderly manner or otherwise disrupts an examination will face disciplinary
action as determined by the Student Conduct Committee. Penalties include a zero
grade for the exam and exclusion from Insearch.
Signed ________________________________
2
PROGRAMMING FUNDAMENTALS SAMPLE FINAL EXAMINATION
Part A – 20 marks
All questions in Part A are worth 2 marks each
ANSWER ALL QUESTIONS IN THIS BOOKLET
a. char
b. int
c. String
d. boolean
3. Write down the correct way to declare and create an object using
the following Constructor method headers:
3
PROGRAMMING FUNDAMENTALS SAMPLE FINAL EXAMINATION
4. Write the Java code to declare and initialise a constant to hold the
value true. You can name it anything you like, but you must choose
the most appropriate data type and assign it the value true.
int j = 0, total = 0;
while (j<100)
{
total = total + j;
}
System.out.println(“total = “+total);
7. Given the following code, what will be the value stored in the
variable x after the code has executed?
4
PROGRAMMING FUNDAMENTALS SAMPLE FINAL EXAMINATION
8. What is the value of the variable k after the following code has been
executed?
int i = 23, j = 2;
double k = (double)i / j;
a. table3D[0][1][0] =
b. table3D[1][0][1] =
5
PROGRAMMING FUNDAMENTALS SAMPLE FINAL EXAMINATION
Part B – 20 marks
Question 1
Write a class Student that has:
Attributes for name, ID and number of subjects
A Student constructor with three parameters used to initialise all
attributes in the class
Accessor and mutator for the student ID
A toString() method to display the Student details
A method that returns true or false depending on whether the
Student is full time (this is true of the Student is studying 4
subjects or more)
6
PROGRAMMING FUNDAMENTALS SAMPLE FINAL EXAMINATION
Question 2 – 4 marks
7
PROGRAMMING FUNDAMENTALS SAMPLE FINAL EXAMINATION
Question 3 – 6 marks
8
PROGRAMMING FUNDAMENTALS SAMPLE FINAL EXAMINATION
Part C – 20 marks
There are two questions in Part C worth 10 marks each
Below is some code for three classes: they are Party, Australian and
French. Line numbers printed on the left are to be used in the questions,
they are NOT part of the Java code.
Question 1
Study the code carefully, then answer these questions:
a. (5 marks) Write down the line numbers in execution order,
starting from line number 6:
b. (1 mark) How many class attributes does the class Party have?
9
PROGRAMMING FUNDAMENTALS SAMPLE FINAL EXAMINATION
10
PROGRAMMING FUNDAMENTALS SAMPLE FINAL EXAMINATION
11
PROGRAMMING FUNDAMENTALS SAMPLE FINAL EXAMINATION
Question 2
a. (4 marks) Write a function called double getNumberOfHours()
that asks the user to enter the total number of hours they wish to hire a
car for (as double) and returns the number of hours. If the number of
hours entered is less than or equal to zero, or greater than 300 the
function should return a value of -1.0 indicating the value is not within
the valid range.
12
PROGRAMMING FUNDAMENTALS SAMPLE FINAL EXAMINATION
b. (6 marks) Write the Constructor of the class CarHire that calls the
method getNumberOfHours(). If the hours entered was within the
valid range then display a confirmation message on the screen that
the car hire will proceed, and display the number of days for the car
hire ROUNDED TO TWO DECIMAL PLACES. Use the formula:
If the hours entered was invalid (if -1.0 was returned from the function)
then display an error message to the user.
END OF EXAMINATION
13