COMP213 - Advanced Object-Oriented Programming Flashcards
Define ‘immutable’
An object whose state cannot be modified after the object is created
What is an object?
An allocated region of storage.
In procedural programming it can contain data or instructions but not both, in object-oriented programming it may contain data and instructions for that data.
What is an array?
A container object that holds a fixed number of values of a single type.
What is an element?
An item in an array
What is a class?
A template/blueprint that will be used in constructing objects. It may contain fields that describe its state or methods that determine its behaviour
What is public/private data?
Public data can be accessed from any class or method (e.g. card.name to access the public 'name' variable in the card class) Private data can only be accessed within its class
What are access modifiers?
A command word that specifies whether a variable is public, private or secret
What is API?
Application Program Interface (e.g. Javadoc)
What tags are available in Javadoc?
Any HTML tags as well as: @author your name @param the parameters of the method (on separate lines) @return what the method holds @throws what exceptions can be thrown @version number or date of code @since when this part has first existed
What are local variables?
Variables declared within a method
What are instance variables?
Variables declared within a class, not within a method
What does the keyword ‘this’ do?
References the current object (e.g. this.name is the instance variable ‘name’, as opposed to the local variable ‘name’)
What is the initial value of an integer?
0
What is the initial value of a float?
0.0
What is the initial value of a boolean?
false
What is the initial value of a reference variable?
null
What does a class constructor do?
Creates objects from the class blueprint
How are identical methods distinguished?
By the types of their parameters
What is a nested class?
A class declared inside another class (not a subclass or extension of a class)
What are the two types of nested class?
Static nested classes with the modifier ‘static’
Non-static nested classes called ‘Inner’
What are the motivations for implementing nested classes?
logical grouping: if a class is only useful to one other class, it is logical to nest it within encapsulation: if a nested class is private within its top-level enclosing it is invisible to the outside world more readable code: nesting small classes within top-level classes places the code closer to where it is used
What is a queue?
A first-in-first-out (FIFO) data structure
What is a java interface?
An abstract type that is used to specify a behaviour that classes must implement (e.g. a queue specifies that methods are needed to (a) take element from the head and (b) add an element to the back)
What is inheritance?
The process where one class gets non-private properties (methods and fields, but not constructors) of another.