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

Mapa mental

Objects and Classes

Hae Won Kim Inglês

Conteúdo do mapa

Objects and Classes

  1. Class

    • "A blueprint or template to create objects of identical type"
    • "Fundamental building blocks of a Java program"
    • class className { [class body] }
      • Class names use the Pascal naming system - capitalize the first initial of each word.
    • UML Class Diagram
      • Top: Class name, Middle: list of fields, Bottom: list of methods
        • Fields and types are separated by a colon.
        • A method's arguments are presented in parentheses and its return value is written after a colon.
      • Provides a summary of all fields and methods
    • Object
      • Fields
        • Variables - can be primitives or references to objects
      • Methods
        • Defines actions that objects or instances can do
        • Declaration Part
          • Return Value
            • Can be a primitive, object, or void
              • return type void means method returns nothing
          • Method Name
          • List of Arguments
            • If a method takes more than one argument, separate arguments with a comma.
          • Also known as the signature of the method
        • Body
          • Contains code that performs the action
        • returnType methodName (list of arguments)
        • Method main
          • Provides the entry point to an application
          • public static void main (String [ ] args)
          • Can pass arguments to main when using Java to run a class
            • To pass arguments, type after the class name
              • java className arg1 arg2 arg3 ...
      • Method and field names use the camel naming system - capitalize the first initial of each word except the first word.
      • Also known as an instance
      • A new keyword can be used to create an object.
        • new is followed by the constructor of the class that is being created.
        • Assign the created object to an object or reference variable with the same type as the object to manipulate the object.
        • Once an object is created, methods can be called and fields can be accessed.
          • Use a period (.) to call a method or field.
        • When an object is created, the JVM performs initialization to assign default values to fields.
      • Null keyword
        • Reference variable has no value.
        • When declaring a local reference variable within a method without assigning an object, assign null to satisfy computer.
        • Null does not need to be assigned to class-level reference variables as they will be initialized when an instance will be created.
        • Trying to access the field or method of a null variable reference will raise an error.
        • Test to see if a reference variable is null by using the == operator.
    • Constructor
      • Every class must have a constructor.
        • If a class does not explicitly define a constructor, the compiler will automatically add one.
          • no-arg constructor
            • Constructors with zero argument
          • Addition will be implicit and not displayed in source file.
        • Must have same name as the class
      • Used to construct an object
      • Also known as constructor method; looks like a method
        • Unlike methods, constructors do not have a return value.
      • constructorName (listOfArguments) { [constructor body] }
  2. Object-Oriented Programming (OOP)

    • Models application on real-world objects

Informações

Descrição
Mapa Mental sobre Objects and Classes, criado por Hae Won Kim em 05-09-2019.
Criado por
Hae Won Kim
Visualizações
0
Avaliação

Fale Conosco

Sobre o que é sua mensagem?

O que você acha do novo visual?

Você gostou?