Learning the Java Language Flashcards
Real-world objects contain ___ and ___.
state and behavior
A software object’s state is stored in ___.
fields - je uložený
A software object’s behavior is exposed through ___.
methods - je odhalené prostredníctvom
Hiding internal data from the outside world, and accessing it only through publicly exposed methods is known as data ___.
encapsulation - Skrytie interných údajov pred vonkajším svetom a prístup k nim iba prostredníctvom verejne prístupných metód sa nazýva zapuzdrenie údajov.
A blueprint for a software object is called a ___.
class - Návrh softvérového objektu
Common behavior can be defined in a ___ and inherited into a ___ using the ___ keyword.
superclass subclass extends - a zdediť do podtriedy pomocou kľúčového slova extends.
A collection of methods with no implementation is called an ___.
interface - Súbor metód bez implementácie sa nazýva rozhranie.
A namespace that organizes classes and interfaces by functionality is called a ___.
package
The term API stands for ___?
Application Programming Interface - Termín API je skratka pre
The Java programming language defines the following kinds of variables:
- Instance Variables (Non-Static Fields)
- Class Variables (Static Fields)
- Local Variables
- Parameters
Instance Variables (Non-Static Fields)
objects store their individual states in “non-static fields”, fields declared without the static keyword. = instance variables, their values are unique to each instance of a class (to each object, in other words); the currentSpeed of one bicycle is independent from the currentSpeed of another.
Class Variables (Static Fields)
field declared with the static modifier; this tells the compiler that there is exactly one copy of this variable in existence, regardless of how many times the class has been instantiated. A field defining the number of gears for a particular kind of bicycle could be marked as static since conceptually the same number of gears will apply to all instances. The code static int numGears = 6; would create such a static field. Additionally, the keyword final could be added to indicate that the number of gears will never change.
Local Variables
Similar to how an object stores its state in fields, a method will often store its temporary state in local variables. The syntax for declaring a local variable is similar to declaring a field (for example, int count = 0;). There is no special keyword designating a variable as local; that determination comes entirely from the location in which the variable is declared — which is between the opening and closing braces of a method. As such, local variables are only visible to the methods in which they are declared; they are not accessible from the rest of the class.
Parameters
public static void main(String[] args) args variable = the parameter to this method. parameters are always classified as “variables” not “fields”.
An expression
is a construct made up of variables, operators, and method invocations, which are constructed according to the syntax of the language, that evaluates to a single value.
The Java programming language is statically-typed
which means that all variables must first be declared before they can be used, the variable’s type and name
byte
is an 8-bit integer, (-128) - 127 (inclusive), for saving memory in large arrays
short
is a 16-bit integer. -32 768 - 32 767, to save memory in large arrays
int
is a 32-bit integer, 0 - 231
long
64-bit integer, The Long class also contains methods like compareUnsigned, divideUnsigned etc to support arithmetic operations for unsigned long.