Programming Practice and Applications Flashcards
Class
a category or type of ‘thing’. Like a template or a blueprint.
Object
Represents ‘things’ from the real world, or from some problem domain
Methods
Methods can have parameters to pass additional information needed to execute. Can also return values
Attributes
Characteristics of an object that is stored in a field
A method signature
Made up of the method name and its parameters
The state of an object
The set of values of all attributes defining an object
Fields
Attributes, they store data persistently and define the state of an object. They are instance variables
Structuring of a field
Always private, starts with a lowercase letter
Private datatype variable_name
Constructor
Initialises an object
Structure of a constructor
Always public, initial values stored in fields, can use parameters, same name as class
Why are constructors public?
So they can be called by anyone who wants to use the class
What are the two types of variables?
Instance variables and parameter variables which only exits while the parameter is being called, then gets called into a field
What does a method do and what is it made up of
Methods implement the behaviour of an object. They are made up of a header and a body
What is a mutator method?
They receive a parameter and they change an object. They have a void return type.
What is an accessor method?
They have a non-void return value and they return a statement about the object.
What is string concatenation?
Merging two or more strings
What is a scope?
A scope is a textual block{ } in Java, which defines where the variable can be accessed
What is a local variable?
A variable that only exists and are accessible within a specific scope. e.g when the method is called
What is the scope and lifetime of a field?
It’s scope is the whole class and its lifetime is the lifetime of its object