Practice exam – sample questions
Exam date and time: Friday 20th August at 2 pm NSW time
Duration: 2 hours
Location: The exam will be conducted online using the TestInvite platform. You will receive the link to the exam closer to the date.
Attention students who are currently located in China
- TestInvite is blocked in China.
- IF YOU ARE IN CHINA PLEASE ADD YOUR DETAILS TO THE FOLLOWING SPREADSHEET – https://scuonline-my.sharepoint.com/:x:/g/personal/alex_hendry_scu_edu_au/EXaaFbKhd1dOmdy1bU5abbABYVtURq_Uh6a_q86uA32QNA?e=jzfkhZ
- You will sit the same exam as other students however you will do the exam via zoom instead of TestInvite.
- This option is only available to students who are located in China at the time of the exam.
ALL STUDENTS please note that:
- ALL students will need a webcam to take the exam. If you do not own you will need to acquire one prior to the exam.
- ALL students must have their student id at the exam and will be required to show it to start the exam.
- The exam is must pass meaning if you do not pass the exam you do not pass the unit.
- These are some sample questions, the number of the questions in the real exam will vary.
- The exam is designed to be easily passable by a student who had attended class and completed the workshop activities.
- The exam is NOT closed book meaning you can assess the study guide, textbook etc. You are also allowed to look at Java documentation or other resources online. HOWEVER, YOU CAN NOT COPY AND PASTE ANYTHING FROM ANY RESOURCE INTO THE EXAM. This includes written answers and code. Any attempt to copy and paste any answer from any resource into the exam will be considered academic misconduct.
- The only exception to the copy and paste rule is you ARE allowed to write code in NetBeans then copy the answer into the exam as long as you wrote the code yourself and it is not identical to any code provided to you in class.
- The exam papers will be put through Turnitin to look for any identical answers. Identical answers from any students to any question will mean that the students have copied the answer from a resource (i.e. study guide, website) into the exam paper. Any students found to do this will be submitted for academic misconduct and will fail the unit.
Part A: Short Answer Questions.
- What is polymorphism? (2 marks)
- What is the difference between accessor method and mutator method? (2 marks)
- What annotation is used when implementing a method from an abstract class or interface?
- What is an overloaded constructor? (2 marks)
- What is the difference between Iterator and ListIterator ? (2 marks)
- Provide 2 differences between linkedList and ArrayList. (2marks)
- Explain what the Super keyword is used for in Java (2 marks)
- Write 2 example method signatures for an overloaded method called getName (2 marks)
- Write the code for an interface called Car that has a method called numberOfWheels that returns an integer (4 marks)
- Write a constructor for the Date class given the following sample object creation code (2 marks)
new Date(“March”, 30, 1932);
- Write a default constructor for the Date class above (2 marks)
- Given the Animal class below, create a class Dog that inherits animal. The Dog class must have at least 2 instance variables that are initialized in a constructor (6 marks)
abstract class Animal
private int numberOfLegs;
private String colour;
protected Animal(int numberOfLegs, String colour)
this.numberOfLegs = numberOfLegs;
this.colour = colour;
public abstract String colour();
- Write the code to use a ListIterator
to loop through the following LinkedList (2 marks)
- Write a declaration for a new HashSet of Person objects, called students. Initialise the new HashSet. Note: you may leave it empty (2 marks)
- Write the code to add a Person object to the HashSet declared for question 14 above. Assume the Person class has a default constructor (2 marks)
- Write a class called Cat that implements the Animal interface shown below (6 marks)
public interface Animal
String colour(); // return colour
void newColour(String s); // update colour
Part B: Java Programming Problems.
- Write a program in Java to store a collection of movie names. There should be no duplicate movies in the collection. The program must contain a method for each of the following: (20 marks):
- add a movie
- remove a movie
- check if a movie exists
- delete all movies
- print out the number of movies
- print a list of all movie names
Hint: each method that does something with a particular movie will need a parameter.
- Write a program in java that implements a HashMap to store students (student ID as the key, and student name as the value). The rogram only requires one method that: (10 mark):
- adds 4 students to the HashMap
- prints all students’ names
- removes all of the students at once