Java Flashcards
Learn Theory (61 cards)
What is encapsulation?
The idea of wrapping variables and methods together into a single unit. It makes use of the “protected” access modifier.
What does protected mean?
Like private, it will not be accessible to other classes but now with the exception of inherited classes. i.e classes that extend from a superclass. Subtypes will have access to any protected and public methods.
If the constructor has been given to a superclass does the subclass need to define one?
No! By default the subclass object will refer to the superclass’s constructor!
How does a subclass constructor invoke a superclass constructor?
With the “Super” keyword. This allows the constructor of the subclass to have its own traits as well as the traits from the parent class.
What are the two types of relationships you can have when it comes to inheritance?
Is-a relationship (Extension)
Has-a relationship (Composition)
What is “#” mean in UML design?
“protected”
How many classes can you inherit from?
1
Can you use subclass properties through a superclass binding?
No
List (the) seven Primitive types.
Int, float, double, boolean, char, short, Byte, Long Boolean.
What is the memory allocation and the range for Boolean?
Range: True, False
1 byte
What is the memory allocation and the range for byte?
[-128, 127]
1 byte
What is the memory allocation and the range for short?
[-32768, 32767]
2 bytes
What is the memory allocation and the range for int?
big
4 bytes
What is the memory allocation and the range for long?
massive.
8 bytes
What is the memory allocation and the range for float?
big.
4 Bytes
What is the memory allocation and the range for double?
Massive.
8 bytes
What is the memory allocation and the range for char?
[0, 65535]
2 Bytes
What is the memory allocation and the range for String?
Very Long
Variable memory.
Why do we have types?
To confirm what we are dealing with and to sort memory allocation.
What does a stack based language mean?
When a method is executed it is put into the call stack. The method being executed at the top of the stack is the most recently called method..
What will be returned when you first initialise an array then call it ?
The memory address!
What type is an array?
Reference type.
True or False. Strings are mutable?
False, Strings are immutable.
What does UML stand for?
Unified Modelling Language