Jetzt loslegen. Gratis!
oder registrieren mit Ihrer E-Mail-Adresse

1. Class

1.1. What Is

1.1.1. A class defines the properties and behaviors for objects.

1.1.2. Programmer-difined type

1.2. >> template defines object’s data fields and methods >> non-static parts of classes describe objects

1.2.1. Objects Declare syntax: ClassName objectRefVar; Declaration - Creation - Assigning syntax: ClassName objectRefVar = new ClassName(); Object's members accessing objectRefVar.dataField objectRefVar.method(arguments)

1.3. Generic Syntax: modifier class ClassName <extends SuperClass implement Intreface> { // field, constructor, and // method declarations }

1.3.1. Class Header modifier public protected default private abtract Class Abtraction ClassName extends SuperClass implement Interface

1.3.2. Data Fields Syntax: modifier datatype dataFieldName; modifier Data Encapsulation private datatype dataFieldName; Properties Accessor Mutator static Variable Tips & Tricks instance Variable Default values reference type: null numeric: 0 boolean: false char: \u0000 no default value to a local variable inside a method

1.3.3. Method Instance method Tips & Tricks Static method Tips & Tricks Syntax: modifier returnValueType methodName(list of parameters) { // Method body; } modifier returnValueType methodName parameters (agrs) method body

1.3.4. Constructor properties same name its Class special kind of method don't have return type (not even VOID) can be overloaded (agrs optional) don't belong to objects Syntax: modifier ClassName(arguments) { // block of statements } modifier arguments invoke Contructor to create Object syntax: new ClassName(arguments); computer gets a block of unused memory in the heap initializes the instance variables of the object

2. Modifiers

2.1. Visibility modifiers

2.1.1. public

2.1.2. default

2.1.3. protected

2.1.4. private methods and data fields accessible only from within its own class