O GoConqr está de visual novo! Conte para nós o que você achou.

Mapa mental

Objects and Classes

Kevin Benitez Inglês

Conteúdo do mapa

Objects and Classes

  1. Every object can have fields(attributes) and/or methods(actions).

  2. Class: Blueprint for the object

    • Needs: Class name, fields, methods
      • Class declaration: must use keyword class
        • {} are used after class for the body
        • Every class must have at least one constructor
          • Looks like a method
          • Does not have a return value
          • Must have same name as class
          • constructorName (listofArguments) { [constructor body] }
            • Used to initialize fields in object
              • new Employee(20, 90000.00);
            • public className (int arg1, method arg 2)
    • Class definition must be saved in file with same name as class name with .java
  3. Fields are variables for the class in question

    • Fields can refer to another object as well
      • Follow camel naming convention (add,dataType,etc.)
  4. Methods define actions of a object

    • returnType methodName (listofArguments)
      • double getSalary() returns a double with no accepting arguments
      • int add(int a, int b) accepts two arguments and adds them
    • Main provides entry point to an application
      • One of the classes in an application needs to have a main method
        • public static void main(String[] args)
        • Can pass arguments to main when using java to run a class
          • java className arg1 arg2 arg3...
  5. Assign created object to an object reference variable

    • objectReference.methodName
    • objectReference.fieldName
    • When reference variable does not have value, it has a null value
      • If (book == null){ book = new Book(); }

Informações

Descrição
Mapa Mental sobre Objects and Classes, criado por Kevin Benitez em 20-05-2021.
Criado por
Kevin Benitez
Visualizações
0
Avaliação

Fale Conosco

Sobre o que é sua mensagem?

O que você acha do novo visual?

Você gostou?