Mapa mental
Objects and Classes in Java
Contenido del mapa
Objects and Classes in Java
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
- returnType methodName (listOfArguments)
- The Method Main
- The method main acts as the entry point to an application. It allows the class containing it to be invoked.
- 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.
- Fields
- Definition: A model that represents a real situation used to solve the main problem. An object consists of attributes (fields) and actions (methods/functions)
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] }
- 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.
Información
- Descripción
- Mapa Mental sobre Objects and Classes in Java, creado por Diego Vargas el 21/05/2021.
- Creado por
- Diego Vargas
- Visitas
- 1
- Valoración