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

Mind map

Pages 75-84

Gary Jones English

Map content

Pages 75-84

  1. Class Members in UML Class Diagrams

    • UML allows you to include field types and method signatures
      • Field and its type is separated by a colon
      • A methods argument list is presented in parentheses and its return comes after a colon
  2. Creating Objects

    • Object = instance
      • Construct = create
        • Instantiating a class = creating an instance of the class
    • Create an Object
      • Use keyword new followed by the constructor of the class to be instantiated
        • new Employee(); is how to make a new Employee object
          • Manipulating the object later
            • Assign the object to an object variable (reference variable)
              • Declare an object reference with the same type as the object
                • Employee employee = new Employee()
            • Once an object is made you can call its methods and access its fields
              • Use the object reference that was assigned to the object using a .
                • ObjectReference.methodName
                  • Employee employee = new Employee(); Employee.age = 24; Employee.salary = 50000
  3. The Null Keyword

    • Reference variable refer to an object but those objects may not have variables = null
      • Class level reference variables are initialized upon instance creation and do not need to have null assigned. But local references do need null assigned
        • Accessing the field or method of a null value raises an error. You can test this by using ==
          • if (book == null) { book = new Book();}
  4. Objects in Memory

    • When variables are declared in the class or method level memory space is used for them
      • declaring an int costs 4 bytes while declaring a long uses 8 bytes. These are primitive values
        • Stored in Javas stack
      • Objects data is stored in Javas heap
      • Reference variable have data stored in Javas stack but the data stored is only the address of the object in the heap
    • Stack data holds reference points that request data while Heap data holds the information
  5. Java Packages

    • Allow you to group related classes or classes with similar functionality
      • Java.io package = classes for performing input and output operations
    • Java packages that start with JAVA are reserved for the core libraries
    • Packages starting with javax are meant for extension libraries
    • Classes with the same name can be used if they belong to different packages
    • To group a class to a package use the keyword package followed by the package name. package com.brainysoftware.common
    • fully qualified name = class name that carries with it its package name
  6. Encapsulation and Access Control

    • This is a mechanism that protects parts of an object that need to be secure. It also only exposes the parts that are safe to be exposed.
      • 4 access control modifiers in Java: PUBLIC, PROTECTED, PRIVATE, and DEFAULT ACCESS LEVEL
        • CLASS ACCESS CONTROL MODIFIERS
          • Access control modifier at the beginning of the class declaration allows you to control from which packages your class can be seen
            • Make a class public by using the public access control modifier
            • A class whose declaration bears no access control modifier has default access

Information

Description
Mind Map on Pages 75-84, created by Gary Jones on 19/05/2019.
Created by
Gary Jones
Views
0
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?