GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Mindmap

Objects and Classes | Mental Map

Phenom Cloud Englisch

Inhalt der Mindmap

Objects and Classes | Mental Map

  1. Constructors

    • In order to instantiate an object, every class is required to define one constructor at minimum. Without a constructor, no Java objects can be constructed and thus the class would be obsolete. Although a constructor is also recognized as a constructor method, they do not yield a return value, including void, unlike a function. Moreover, any constructor needs to hold an identical name as the class. If a class explicitly defines a constructor, the Java compiler will not add any additional constructors. Despite this, if a class does not explicitly define any constructors, then the compiler will add a no argument or zero argument constructor to the class, which will not be displayed in the source file.
      • Objects
        • Java objects or instances, similar to real life counterparts, may contain the following two features: attributes and actions to perform. As observed with birds, for instance, some attributes may include wingspan, plumage color, beak shape, and species, while being able to conduct a variety of actions such as flying, nesting, and preening. Despite this, in contrast to physical objects, the attributes and actions of a Java object are optional; thus, some Java objects may yield one, two, or none of the previously mentioned features. Utilizing the "new" keyword, an object can be successfully created. Typically, it is recommended that the created object should be assigned to an object or reference variable, largely so the object can be manipulated in the future. Once an object is constructed, its methods can be called and its fields accessed through the object or reference variable. However, sometimes it does not contain a value or object reference, hence having a null value.
          • Fields
            • Also known as attributes, fields are variables that can be primitive data types or references to Java objects. Moreover, a field can also refer to multiple objects, as seen with the example of a bird class having a food diet of type food diet. As demonstrated in the previous situation, if the class of an object holds variables that references other objects associated with other classes, then an object of the former class can essentially contain other objects. In contrast to class naming conventions, field names also adhere to camel case, where the initial of each word except for the first term is capitalized.
          • Therefore, attempting to access any field or method of a null variable reference can result in a technical error.
      • Classes
        • Java classes serve as the framework or template to manifesting objects of an identical type. Through the successful creation of a bird class, for example, any amount of bird objects may be formed. Therefore, if the bird class is assigned a size field and perching method, all bird objects instantiated from this class will also inherit these behaviors and properties as well. In other words, classes build the necessary foundation towards creating a Java program. Regardless of whether object-oriented features are utilized, all program elements must be contained within a class. Broadly speaking, three aspects that may be considered when writing a Java class includes the following: the class name, fields, and methods. According to convention, any chosen class names capitalize the initial of each word in a naming custom known as Pascal case. Notably, class definitions are also required to be saved in a file, yielding a java extension (.java format), that holds the same name as the class
          • Methods
            • Also known as functions, methods define the actions of a class's objects. Moreover, methods preserve both a declaration part and a body; the former consists of a return value, method name, and a list of arguments, while the latter yields the necessary code to execute an associated action. Within the declaration part or signature of a method, the return type can be a primitive data type, an object, or void, which indicates the method returns nothing. In contrast to class naming conventions, method names also adhere to camel case, where the initial of each word except for the first term is capitalized.
              • Methods: Main
                • In order to facilitate an entry point into any Java application, a unique method known as "main" must be provided in only one of the written classes. Through this function, the class containing it can be invoked. Furthermore, arguments, all of which must be passed as strings, can also be passed to the main method when using java in order to run a class.

Informationen

Beschreibung
Mindmap am Objects and Classes | Mental Map, erstellt von Phenom Cloud am 01/08/2019.
Erstellt von
Phenom Cloud
Aufrufe
0
Verlauf
  • Erstellt von Phenom Cloud · 15 Mai 2019
  • Kopiert von Phenom Cloud · 1 Aug 2019
Bewertung

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck