OOP Flashcards
What is inheritance? Provide a simple code example. (8 marks)
Remember self
What is polymorphism? Provide a simple code example. (8 marks)
When developing a software system for a greengrocer, a developer decides on
the following rules: Many APPLES are stored in one BARREL and many
ORANGES are stored in one BASKET. APPLES have a colour and weight, and
you can PICK and SQUEEZE apples. ORANGES have a WEIGHT and a
DATE_PICKED, and you can also PICK and SQUEEZE them. BARRELs and
BASKETs have a SIZE, and you can SELL or DISCARD either.
Draw a CLASS DIAGRAM to represent the above scenario.
(8 marks)
Develop a program in Java to calculate the average value in an integer array,
creating a AvgArray method, with a main method, all enclosed in an
AArray class.
(9 marks)
What is overriding?
(3 marks)
Create a Java program including all the methods and classes to demonstrate
overriding.
(12 marks)
Show how you would create two instances of the two classes you created in
part (b) of this question.
(8 marks)
What is super? Provide a simple code example.
(10 marks)
Explain what each of the following parts of a Class Diagram does:
* Method, Attribute, Class, Association, Generalization.
(10 marks)
Express the following as a Class Diagram:
In general, a CUSTOMER can place more than one
ORDER. The CUSTOMER has a credit rating. The ORDER
can dispatch and close orders. There are two
specific types of CUSTOMER, a CORPRATE CUSTOMER and
a PERSONAL CUSTOMER. The difference being that a
CORPRATE CUSTOMER will be given a reminder to pay
their invoices, and they can request a total bill
for the month.
Express the following as a Class Diagram:
A STUDENT takes a specific ENROLLMENT of a given
SEMINAR. Once they are enrolled the STUDENT name is
added to the SEMINAR list. The STUDENT has to be
eligible to enroll, and must record the number of
seminars taken. The SEMINAR can add and drop
students. The ENROLLMENT can get the average mark to
date and get the final mark.
A PROFESSOR will give the SEMINAR, and one PROFESSOR
can give zero or more seminars.
(13 marks)