csc223 final study guide

Object-Oriented Programming Concepts

Object

  • Definition: A region of memory that has a value.

  • Characteristics: Has a name, behavior, and can receive messages.

Program Types

  • Object-Oriented

  • Object-Based

  • Procedure-Based

Object Properties

  • Object State: How the object appears (structure, creation, access).

  • Object Behavior: How the object reacts to messages.

    • Internal Behavior: Implementations of actions and performance of objects.

    • External Behavior: Determined by the program interface; users can use the program without knowing the internal details of the object.

Abstraction

  • Definition: Separates external behavior from internal implementation.

Runtime Errors

  • Cause: Can be caused by incorrect binding.

Binding Concepts

Types of Binding

  1. Early/Static Binding

    • Information available during compile time; modules and functions connected during compilation.

  2. Late/Dynamic Binding

    • Information available during runtime; modules and functions connected during execution.

    • Uses: Polymorphism in OOP.

Polymorphism

  • Definition: Ability for an object to take multiple forms; operations differ based on the receiving object; class determines behavior.

  • Types: Static and dynamic polymorphism.

    • Static Polymorphism: Methods overloaded with different signatures in the same class.

    • Dynamic Polymorphism: Methods overloaded with the same signature in different classes.

Inheritance

  • Definition: Subclasses can inherit data from a superclass.

  • Subclass Behavior: Can override base members; inherits methods and variables from superclass.

  • Types of Inheritance:

    • Simple Inheritance: Subclasses extend 1 base class.

    • Multiple Inheritance: Subclasses extend 2 or more base classes.

  • Access Modifiers:

    • Protected Modifier: Child classes get access.

    • Private Modifier: Authorized access only.

Abstraction Components

  • Definition and Declaration:

    • Definition: Defines methods and structures to operate class variables.

    • Declaration: Declares members and necessary objects.

Encapsulation

  • Definition: Binds data and code, preventing unauthorized access.

JVM (Java Virtual Machine)

  • Definition: Manages memory allocation/deallocation.

  • Memory Types:

    • Stack Memory: Stores local variables, function arguments, and their return address.

    • Heap Memory: Stores instances of classes; dynamically allocated.

Static Methods

  • Definition: A method that receives all data from the argument.

  • Calling Static Methods:

    • Internally: this.method();

    • Externally: Class.object.method(parameters);

  • Storage Location: Stored in Permanent Generation Space (PGN) of the heap.

Parameter Types

  • Formal Parameter: Receives value in a method call.

  • Actual Parameter: Passes value in a method call.

  • Value Parameter: Passes value, not the address.

  • Reference Parameter: Passes reference to an address.

Data Types

  • Primitive Data Type: System-defined data types that come with the language.

  • Reference Data Type: Refers to an object in memory.

Instructions

  • Components:

    • Opcode: Specifies the operation.

    • Operand: Data to be operated on.

  • Addressing Types:

    • Direct Addressing: Operand holds the actual address.

    • Indirect Addressing: Operand holds a reference address to the value.

Memory Management

Declaration Process

  • Definition: Allocates and reserves storage space for the declared data object.

Garbage Collection

  • Purpose: To reclaim memory from lost objects that cause shortages.

  • Lost Objects: No longer have pointers, resulting in wasted space.

  • Automatic Dereferencing: JVM process to manage garbage collection.

String Class Constructors

  • Constructors Available:

    • (), `(