cs paper 2 revision terms

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/81

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 10:24 PM on 5/1/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

82 Terms

1
New cards

What is a class?

A blueprint or template that defines the data and methods objects of that type will have. It is the code definition — not a real object. Like architectural drawings before any house is built.

2
New cards

What is an object?

A specific instance created from a class. Each object has its own copy of the instance variables. Multiple objects can exist from one class

3
New cards

What is instantiation?

The process of creating an object from a class. Memory is allocated for the new object and the constructor runs automatically. Done in Java with the new keyword.

4
New cards

What is a constructor?

A special method that runs automatically when an object is created. In Java

5
New cards

What is an instance variable (attribute/property)?

A variable stored inside each object. Every object of the same class gets its own separate copy. Also called a property or field — it describes the object's state.

6
New cards

What is a method?

A function that belongs to a class. It defines what an object can DO. Methods can access and modify the instance variables of the object they belong to. Also called behaviours.

7
New cards

What is encapsulation?

Wrapping data (attributes) and the methods that use that data together into a single unit (the class)

8
New cards

What is an accessor (getter)?

A method that allows code outside the class to READ the value of a private attribute. Returns the value without letting external code change it directly. Named with get prefix by convention.

9
New cards

What is a mutator (setter)?

A method that allows code outside the class to WRITE (change) the value of a private attribute. Can include validation before setting. Named with set prefix by convention.

10
New cards

What does private mean?

An access modifier. A private attribute or method can only be accessed from within the same class. External code cannot read or change it directly — must use accessors/mutators.

11
New cards

What does public mean?

An access modifier. A public method or attribute can be accessed from any class in the program. Accessor/mutator methods and behaviours are usually public.

12
New cards

What does static mean?

The variable or method belongs to the CLASS itself

13
New cards

What does this mean in Java?

A keyword used inside a class to refer to the CURRENT object. Needed when a parameter name and an instance variable share the same name (e.g. this.name = name).

14
New cards

What is inheritance?

A mechanism where a child class (subclass) automatically receives all non-private attributes and methods of a parent class (superclass). The child can add new features or change existing ones. Java: extends keyword.

15
New cards

What does super() do?

Calls the parent (superclass) constructor from inside a child class constructor. Must be the first line in the child constructor. Passes required parameters up to the parent.

16
New cards

What is polymorphism?

The ability for objects of different classes to respond to the same method call in their own specific way. Achieved through overriding (same name

17
New cards

What is overriding?

When a child class provides its OWN version of a method that already exists in the parent class. The child's version replaces the parent's for that object type. Same method name

18
New cards

What is overloading?

When a class has multiple methods with the SAME name but DIFFERENT parameter lists (different types or number of parameters). Java decides which version to run based on the arguments passed.

19
New cards

What is an abstract class?

A class that cannot be instantiated directly — you can never do new AbstractClass(). It defines method signatures that subclasses MUST implement. Acts as a contract. Java: abstract keyword.

20
New cards

What is aggregation?

A "has a" relationship where one class contains an object of another class as an instance variable

21
New cards

What is a dependency (uses) relationship?

One class uses another temporarily — typically as a method parameter that is not stored as an instance variable. In UML: dashed arrow + "uses" label.

22
New cards

What is an association (has a) relationship?

Two classes have an ongoing relationship but can exist independently. Often one-to-many. In UML: double-headed arrow + "has a" label.

23
New cards

What is a method signature?

The combination of a method's NAME and its PARAMETER LIST (types and order). The return type is NOT part of the signature. Used to distinguish between overloaded methods.

24
New cards

What is a UML class diagram?

A visual diagram showing classes as 3-row boxes (name / attributes / methods) and the relationships between them using specific arrow types. Used to plan and communicate OOP design.

25
New cards

In UML notation

what does – (minus) mean?

26
New cards

In UML notation

what does + (plus) mean?

27
New cards

In UML notation

what does # (hash) mean?

28
New cards

How do you write an attribute in UML format?

– attributeName: type (e.g. – registration: String) for private. Use + for public.

29
New cards

How do you write a method in UML format?

  • methodName(paramType): returnType (e.g. + pay(int hours): double). Constructor has no return type.
30
New cards

What arrow type represents inheritance in UML?

Solid arrow with hollow arrowhead pointing from child UP to parent. Label: "is a". Example: Car —is a→ Vehicle

31
New cards

What arrow type represents aggregation in UML?

Hollow diamond on the "owner" side with an arrow pointing to the owned class. Label: "has a". Example: ParkingArea ◇—has a→ Vehicle

32
New cards

What arrow type represents dependency in UML?

Dashed arrow. Label: "uses". Example: Borrower - - uses - -→ Book

33
New cards

What Java keyword is used for inheritance?

extends (e.g. class Car extends Vehicle)

34
New cards

What Java keyword is used to call the parent constructor?

super() — must be the FIRST line in the child class constructor.

35
New cards

What is the output of: Vehicle v = new Vehicle("X1234567")

36
New cards

v.setBroken(true)

37
New cards

System.out.println(v.getRegistration())

38
New cards

X1234567 — the constructor stores the registration

39
New cards

What does this.name = name mean inside a constructor?

this.name refers to the instance variable. name (right side) is the constructor parameter. this. is needed because both have the same identifier.

40
New cards

What happens when you call `new WaterMonster("Splashy"

25)if WaterMonster callssuper(name

41
New cards

Write the array-add pattern in Java (add item to next empty slot

return index

42
New cards

i < items.length

43
New cards

i++) { if (items[i] == null) { items[i] = x

44
New cards

return i

45
New cards

} } return -1

46
New cards

}

47
New cards

Write the array-add pattern using a counter variable (monsterCount style).

public void addItem(Item x) { if (count < items.length) { items[count] = x

48
New cards

count++

49
New cards

} else { System.out.println("Full")

50
New cards

} }

51
New cards

Write the array-remove-and-shift pattern in Java (find item

shift remaining elements left

52
New cards

for (int i = 0

53
New cards

i < count

54
New cards

i++) { if (items[i] == x) { idx = i

55
New cards

} } for (int j = idx

56
New cards

j < count - 1

57
New cards

j++) { items[j] = items[j+1]

58
New cards

} items[count-1] = null

59
New cards

count--

60
New cards

}

61
New cards

Write the array-search-and-return pattern in Java (search by String ID

return object or null).

62
New cards

i < count

63
New cards

i++) { if (items[i] != null && items[i].getID().equals(id)) { return items[i]

64
New cards

} } return null

65
New cards

}

66
New cards

How do you instantiate a subclass called FireMonster with name "Flamey" and 40 health?

FireMonster f = new FireMonster("Flamey"

67
New cards
68
New cards

Give two advantages of OOP (with expansion — mark scheme style).

  1. Code reuse via inheritance — subclasses inherit methods from the superclass
69
New cards

Give two disadvantages of OOP (with expansion — mark scheme style).

  1. Unnecessarily complex for small problems — some applications could be solved in a simpler procedural way without the overhead of defining classes. 2. Larger program size — more code is produced as classes
70
New cards

Give two advantages of modularity (with expansion — mark scheme style).

  1. Faster development — different teams can work on different modules simultaneously
71
New cards

Outline one advantage of making instance variables private.

Data hiding / increased security. This prevents accidental or unauthorised changes to variables from outside the class — any modification must go through a setter method

72
New cards

What is the mark scheme answer for "outline why this is used in setBroken"?

this is needed to distinguish the instance variable broken from the parameter also named broken. Without it

73
New cards

What is the mark scheme answer for "outline why super is used in the WaterMonster constructor"?

super() is a reference to the superclass (Monster). It calls the Monster constructor

74
New cards

What is the mark scheme answer for "outline one effect of the static modifier"?

The variable belongs to the class

75
New cards

Distinguish between a class and an object.

Class: a code definition / template / blueprint — only one exists in memory for static elements. Object: an actual instance created from the class — there can be many objects

76
New cards

What does it mean for Vehicle[] to be a "valid type" for an array that stores both Car and Motorbike objects?

Because Car and Motorbike both extend Vehicle (are subclasses of Vehicle)

77
New cards

What are the two types of methods that allow access to private variables?

Accessor (getter) and mutator (setter). Also accepted: get/set methods.

78
New cards

What is the difference between overriding and overloading?

Overriding: same method name AND same parameters

79
New cards

How do you write a constructor in Java?

Same name as the class

80
New cards

}`

81
New cards

What is the relationship between Car and Vehicle if class Car extends Vehicle?

Inheritance — "is a" relationship. Car is a subclass (child). Vehicle is the superclass (parent). Car inherits all non-private attributes and methods from Vehicle.

82
New cards

What is the relationship between ParkingArea and Vehicle if ParkingArea stores a Vehicle[] array?

Aggregation — "has a" relationship. ParkingArea owns/contains Vehicle objects. ParkingArea depends on Vehicle but Vehicle does not depend on ParkingArea