(English) Important Terms of Java + Object Oriented Programming

You should understand and be able to roughly describe the following terms (and their relations), approaches, facts, etc.:

Object Orientation (OO)

(DE: Objektorientierung) fundamental concept of programming, used in Java (and many other modern programming languages). Based on the idea of objects, which are created from classes and have attributes and methods.

  • Objects can communicate with each other by calling methods of itself or other objects.

  • Objects are created in RAM during program run and destroyed when not needed anymore.

  • They are created from a "blueprint", their class.

  • Objects have a set of attributes (defined within the class), together forming the "state" of the object.

  • Classes are grouped into packages (if no named package, it is called "default package")

  • Important OO concepts: encapsulation, inheritance, polymorphism, abstraction, interfaces, …​

class

(DE: Klasse) blueprint for objects (of that class), describes structure and algorithms in full detail, so that objects can get created.

object, instance

(DE: Objekt, Instanz/Exemplar) created in RAM during program run - gets the memory space to hold values for the instance variables.

object creation/instantiation

(DE: ) done in program by e.g. Person p1 = new Person("Evi", 16); // name, age values to set After getting the needed space in memory, the constructor is called and prepares the object for use.

constructor

(DE: ) default constructor (=no params), constructors with parameters (see above: object creation)

attribute, property, field (=instance variable)

(DE: Attribut, Eigenschaft, Feld, Instanzvariable) holds e.g. name, age, etc during the whole lifetime of the object. is usually hidden from outside access by access modifier 'private'

declaration

(DE: ) of a method, variable, etc.: defining the name and type (and optionally the visibility) of a variable, in case of methods also the patameter list (with their types), but not the implementation (method body) or the value (variable). Class declaration defines the class name and its visibility.

visibility

(DE: ) defines the access rights to a class, method, instance variable, etc. Can be public (visible to all), protected (visible to all in same package and all subclasses), (package) (nothing written! – visible to all in same package), private (visible only to the class itself).
Default is package visibility

method

(DE: Methode) a method (sometimes called "member function") is a named piece of code, which belongs to one class and therefore to its objects. It is defined only once (within the class the method belongs to) and can be used/called many times, providing needed runtime parameter values. The acitvities done during run is often called the "behavior" of the method, for all together the behavior of the object/class.

Together with the other methods of its class they are often the only way to communicate/interact with an object, their signatures define the 'vocabulary', their implementations the behavior. All Objects of the same class have the same set of methods. parameters and return values allow transfer of data between the object for which the method is called and the calling code.

method implementation/definition

(DE: Methoden-Implementation/Definition) done only one time (within the class the method belongs to). All details are written (return type, algorithm, parameter variables, local variables, creation of other objects, calling their methods, etc.)

method use/call

(DE: ) since a method is basically a named piece of code belonging to one class and therefore to its objects, this code can be used by telling one object to run this code (= call the method by name) and adding the needed parameter VALUES at call time. If the method has a non-void return type, a VALUE of the given type is returned when the method is left. NO types are needed to be written, the compiler knows them by looking at the implementation.

method parameter

(DE: ) variable which takes the given value provided by the method caller at call time and provides its value wherever needed within the method body. Its lifetime ends as soon as the processing flow leaves the method (by return xxx or by reaching the method end).

method return value

(DE: ) every method has a return type. This can be void (nothing gets returned) or any other type defined in Java. So every non-void method has to end with a return statement, which provides a return value. This return value can be used in an expression, equivalent to a literal or variable. So the method call effectively leaves at his position the return value as soon as finished.

expression

(DE: ) produces a value of some type (or an object - the type is its class). Can e.g. be a combination (by operators) of literals, variables, method calls with non-void return value, other expression. Can be arithmetic, boolean, relational, textual (string), etc.

operator

(DE: ) arithmetic (, -, *, /, %), relational (>, >=, ==, !=, ...), boolean (!, &&, ||, ...), string (concatenation with ''), assignment (=), …​

statement

(DE: )

conditional statement

(DE: Bedingte Anweisung) (if (…​) { …​ } else if (…​) { …​ } else if (…​) { …​} else { …​ } )

assignment

(DE: ) copies the value (created by evaluation of an expression at the right side) to the variable at the left side

setter

(DE: ) takes a value as single parameter and usually sets the corresponding (hidden) instance variable. Returns void! Usually has some checking code to prevent setting invalid values (e.g. negative age or length). Should be used all the time when changing instance variable values to avoid invalid values. Structure: public void setAge(int age) { if (age < 0) { …​ error msg …​ } else { this.age = age; } }

getter

(DE: ) usually allows accessing the value of a hidden (private) instance variable. Structure: public int getAge() { return age; }. In most cases simply returns an instance variable with corresponding name. But it could also create/calculate a value "synthetically" or do some transformation. .