webprog

Cards (84)

  • Objects
    • Represents either a real world object or an abstraction of a concept
    • Has characteristics or attributes
    • Can have certain states (on/off, true/false, etc.)
    • Can exhibit certain behaviors (in the form of Java methods)
  • Classes
    • Create an instance of an object
    • Define the objects attributes
    • Facilitate inheritance
    • Are "blueprints" for objects
  • Packages
    • A collection of related classes and interfaces grouped together in a single folder or directory
    • Can be imported to a Java program using the keyword import
  • Advanced OOP Concepts
  • Instance Variables
    Variables declared outside any method, constructor or code block, usually declared within a class, can be used on any method within the main class
  • Methods
    Collections of statements that are grouped together to perform an operation, mostly used to categorize such statements according to a specific task or purpose
  • Types of Methods
    • Methods that return a single value or object are used to derive data from a task or operation
    • Methods that perform other actions, such as setting of variable values
  • this keyword
    Used to pertain to the name of an object receiving a method call of a method definition, object variables are usually set as part of the method definition's declaration syntax
  • Local Variables
    Variables declared within a method definition, only visible to the methods in which they are declared, inaccessible from the rest of the class
  • Information Hiding
    A programming mechanism restricting access to some of the object's components, details of a program's code are hidden, especially parts that other programmers or users need not know and/or use, allows a more abstract view of the methods and classes being used in a program, diverts attention of programmers/users to more important programming tasks
  • Public and Private Modifiers
    Collectively known as access modifiers due to the way they restrict access, objects and methods to certain parts of a program, public modifiers have no restrictions on where their corresponding program entities can be used, private modifiers restrict use of their accompanying program entities within their own class method definition
  • Accessors
    A public method that returns data from a private instance variable, also called get methods and getters, method identifiers typically start with the common keyword get along with the name
  • Mutators
    A public method that changes data stored in one (1) or more private instance variables, also called set methods or setters, method identifiers typically start with the common keyword set along with the name
  • Encapsulation

    The process of combining data and actions into a single item, groups instance variables and methods into a class, hides implementation details
  • Exceptions
    Events that occur during the execution of a program that disrupts its normal flow of instructions
  • Exception Handling
    The process used to change the normal flow of code execution if an exception occurs
  • Exception Handling
    • Ensures that the program is still working as intended despite the exception encountered
  • Types of Exceptions
    • Checked Exception
    • Unchecked Exception (Runtime Exception)
  • Checked Exception
    Occurs during compilation, cannot be ignored and should be resolved to continue the program's execution
  • Unchecked Exception (Runtime Exception)
    Occurs during program execution, usually ignored during compilation, some result from data supplied by a program's user
  • try, catch, and finally
    1. try block (code block that may possibly throw an exception)
    2. catch block (code block that can handle an exception thrown by a corresponding try block)
    3. finally block (code block that contains statements executed whether or not an exception is thrown)
  • try block
    Exceptions can be handled by a matching catch block, can be used to detect errors or bugs that need to be fixed
  • catch block
    The try block associated to the catch block must precede it in order to work, may not work if the associated try block does not contain sufficient resources to work with
  • finally block
    Provides the actual "continuation" of the program execution process after a given exception, whether an exception was caught and handled or not
  • User-Defined Exceptions
    Exceptions defined by the programmer, can be created by extending the Exception class via the extends keyword
  • Inheritance
    Enables the use of an existing class to define new classes
  • Inheritance
    • Uses the keyword extends
  • Derived Classes
    Also known as subclasses, child classes, and descendant classes. Defined by adding instance variables and methods to an existing class.
  • Base Classes

    Also known as superclasses, parent classes, and ancestor classes. The existing class where the derived class is built upon.
  • Derived classes do not inherit constructors from its base class
  • Constructors in Derived Classes
    Invoke constructors from the base class. Use the super keyword to call a constructor in the base class.
  • this method
    Calls the constructor of the same class when used in a constructor. Can be instantiated without a value.
  • Polymorphism
    Ability of an object to take on many forms. Allows changes in the method definition for the derived classes to apply to the methods written in the base class.
  • Dynamic Binding
    Programming mechanism where the definition of a method is not bound to an invocation of the method until runtime when the method is called. Used when the compiler does not have enough information to verify that the method even exists.
  • Interfaces
    Used to specify methods that a class must implement. Contain headings for a number of public methods.
  • Abstract Classes
    Classes that cannot be instantiated but can be subclassed. May or may not include abstract methods (methods that do not have a body). Objects cannot be created from this class.
  • Abstract Methods

    Methods that do not have an implementation. Written without braces ({}), instead require a pair of parentheses (( )) followed by a semicolon (;). If included in a class, the class itself must also be declared as an abstract.
  • Class Type Variable
    Contains the memory address of the object named by the variable
  • Reference
    Address of the memory location for the object
  • equals() method
    Used as the proper alternative to the == (equal to) operator; the == operator checks whether two (2) values have the same memory address, not the equality of their values