Crying for Midterm 1 Flashcards
The Metaphor of the Object_Oriented Paradigm
Everything is an object
A class is a collection of objects
Implementor, Client, Designer
Implementor: Formulates the algorithms
Client: instantiates objects and uses methods
Designer: defines abstractions and chooses interfaces
Abstraction
Polymorphism; specifically how it can relate to inheritance and such
Composition
The idea of objects attributes being other objects
Attributes, Methods, and Constructors
Attributes: data stored inside of an object
Methods: Behaviors stored inside of objects/classes used to instantiate the objects
Constructors: only available in Classes, used to instantiate objects themselves (making sure they are stable)
Encapsulation is a common theme with attributes and methods
Definitions of an “interface”
- GUI that we all know and love
- Java keyword interface
- The interactions between Objects and Classes and their respective interfaces
- The Java API
Packages
A storage system used to group together different classes into different positions on a computer.
Classes within the same package can use protected variables
Allows two classes to have the same name but different locations, making “overloading” names possible
Design: object responsibilities
An objects responsibility is to be stable, have a relatively discrete interface, and to do it’s job and only it’s job.
Objects should have private attributes exclusively.
Objects should have attributes to display necessary information within the general interface.
Abstract classes
CANNOT have constructors
used as a midway between classes and interfaces
can have instance variables
single inheritance
can be made up of abstract methods and normal methods
Abstract methods
methods that consist of only a return type, name, and parameters
Need to be overloaded in child classes w/ methods
Classes
a blueprint for objects
used to define everything that specific object would and could ever need
must have a constructor (if not given one the Java JVM makes one anyways)
Interfaces
CANNOT have a constructor
CANNOT have instance variables
CAN have constant variables
supports multiple implementations
All implementing classes must include all methods present within the interface
All interface methods MUST be abstract
Polymorphism
The act of overriding methods in child classes to make them more personal for each specific object
Insanely powerful
When you call a method, you will get specifically the most specific instance of that method if it applies to the object in question
Exceptions
The act of managing things that go wrong in code.
Unchecked exceptions
Exceptions caused by errors present within the implementation that can be fixed by better coding logic
Checked Exceptions
Exceptions caused by things that go wrong during runtime (I/O errors, FileNotFoundExceptions, etc)
throws keyword
Belongs in method signature
used on all methods that throw an exception.
NOT used in try-catch methods within the main method to test code
throw keyword
Belongs in method body
Throw new exception(“String”)
if it is present in the method body, you must use throws in the signature