GoConqr has a new look! Let us know what you think.

Mind map

Objects and Classes in Java

Diego Vargas English

Map content

Objects and Classes in Java

  1. Java Object

    • Definition: A model that represents a real situation used to solve the main problem. An object consists of attributes (fields) and actions (methods/functions)
      • Fields
        • Fields define certain characteristics of the object. They are variables that can be primitives or even references to another object.
        • Fields follow the camel naming convention: age, maxAge, name, lastName, etc.
      • Methods
        • Methods define the actions the object can take. It consists of a a declaration and a body. The declaration has a return value, the method name, and a list of arguments. The body contains the code that performs the action.
          • returnType methodName (listOfArguments)
            • The return type can be a primitive, object, or void. Void means the method returns nothing
        • The Method Main
          • The method main acts as the entry point to an application. It allows the class containing it to be invoked.
  2. Java Class

    • Definition: A class serves as the template used to create an instance of an objects of identical type. The three main things a class should contain is the class name, the object's fields, and the object's methods.
      • class className { [class body] }
      • Class names follow the Pascal naming convention: Boss, PostOffice, StudentGrades, etc.
      • A class definition must be saved in a file that has the same name with the java extension. For example: Employee.java for the employee class.
      • A UML diagram is a useful way to conceptualize a class. It is a rectangle separated into three parts: the class name, the list of fields, and the list of methods.
      • Constructors
        • A constructor is used to construct an object. Every class must have at least one constructor or else the class is useless. Their syntax is similar to that of a method but has no return value.
        • A constructor with zero argument is called a no argument constructor. Constructor arguments can be used to intialize the fields in an object
        • constructorName (listOfArguments) { [constructor body] }

Information

Description
Mind Map on Objects and Classes in Java, created by Diego Vargas on 21/05/2021.
Created by
Diego Vargas
Views
1
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?