Implementing Classes in Java Flashcards
1) UML
ULM stands for: u___________ m____________ L__________________
Unified Modeling Language
2) Designing Classes
Useful to start by using a diagrammatic notation, normally UML.
In this notation, a class is represented by a box divided into three sections.
The first section provides the n______ of the class, the second section lists the a_______, and the third section lists the m_____________.
name
attributes
methods
3) In UML diagrams you will see a (+) or a (-) sign next to certain things.
e.g. -length : double
-height : double
\+Oblong(double, double) \+getLength() : double
What does the (-) mean?
What does the (+) mean?
(-) means that the information is private - accessible only to methods within the same class
(+) means that the information will be public - accessible to methods of other classes
4) getters and setters
methods for r________ and w_________ the attributes conventionally begin with get- and set-respectively.
reading
writing
5) Constructor Methods
Do NOT have a r__________ or a v______ infront of them.
return
void
6)
Attributes of a class are accessible to all the m_______ of the class—unlike l_____ variables, which are accessible only to the methods in which they are declared.
methods
local
7) Public or private?
Unlike the a_________, we want our methods to be a___________ from outside so that they can be called by methods of other classes.
attributes
accessble
8) When we define a constructor in a class;
e.g. public Oblong(double lengthIn, double heightIn)
{
length = lengthIn;
height = heightIn;
}
The constructor is called a ‘u______-d_________ constrctor’.
user-defined constructor
9) Do we have to define a constructor method in our class?
No
10) What happens if we do not define a constructor method in our class?
one is automatically provided for us—this is referred to as the ‘default constructor.’
11) Does the default constructor take any parameters?
No.
I’m not even sure at this point if you would even see it on the screen.
I think it would just work if you created a new object.
e.g. Object my object = new Object( );
12) Can ‘constructor methods’ be overloaded like normal methods?
Yes, their names can also be reused. But again, with different parameters.
13) Developing a class
When developing a class we should always strive to restrict our methods to the e_______ f________ that define the class and to exclude anything that is concerned with the i______or o______ functions of a program.
If we do this, then our class can be used in any sort of application,
essential functions
input
output
14) ‘formal’ vs ‘actual’ parameters
The variables in the brackets of the method signature are the __________________________ of the method.
The _________________ are the values we send when we create a new object
e.g: myOblong = new Oblong(oblongLength, oblongHeight)
formal parameters
actual parameters
15) polymorphism
The technique of overloading method names is a very important feature of OO programming languages and is called p___________________ (having many forms).
polymorphism