Intro to OOP Flashcards
Functions
write an algorithm once to be used in many situtations
Objects
group a related set of attributes and behaviors into a class
Frameworks and APIs
large groups of objects that support a complex activity
can be used “as is” or be modified to extend the basic behavior
Class
A blueprint from which an object is actually made
Describes the state or the data that each object contains
Describes the behavior that each object exhibits
three key features of OOP in classes
- Encapsulation
- Inheritance
- Polymorphism
keyword to create an instance of a class
new
functions that provide processing to the object’s data
determines the behavior of an object
Methods
Collection of all publicly available methods
Class Interface
Accessing object members
dot notation
hides the implementation details of a class
Encapsulation
a method that is automatically invoked when an object is created. It is normally used to initialize data members.
Constructor
Default constructor
- default constructor if not overwritten
- takes no arguments
- no body
what happens when new is called
- Memory is allocated for the new object and instance variables are initialized to their default values
- Explicit attribute initialization is performed
- The appropriate constructor is executed
Parameter passing in Java
Java only passes parameters by value
When an object is passed as a parameter to a method, only the reference is transmitted
package statement
allows for the grouping of classes
import statement
specifies the directory of the packages/classes to be used
Inheritance
- Extends existing classes to support new abstractions
- Factor common attributes and methods in superclass
Method overriding
- the method name from the parent class can be overriden
- If the method has different number and type of parameters, it is still overloading, but if the method has exactly the same signature, it is called overriding.
root of all classes in Java
Objects