Introduction to Computer Science 1- Unit 2 - Object-Oriented Programming

A class

a set of functions that work together to accomplish a task

An object

receives all of the characteristics of a class, including all of its default data and any actions that can be performed by its functions.

A method

refers to a function that is encased in a class.

A parameter

a variable that is passed into a function that instructs it how to act or gives it information to process. Parameters are also sometimes called arguments.

A property

a default set of data stored in a class. A class can have multiple properties and the properties can be changed dynamically through the methods of the class.

DRY

Don't Repeat Yourself and it means just that

KISS

Keep It Simple, Stupid and means that you should try to write code that accomplishes its goal in the simplest manner possible.

object-oriented programming

based on the concept that after an object is written it can be reused

data encapsulation

Hiding internal state and requiring all interaction to be performed through an object's methods

Modularity

The source code for an object can be written and maintained independently of the source code for other objects. Once created, an object can be easily passed around inside the system.

Information-hiding:

By interacting only with an object's methods, the details of its internal implementation remain hidden from the outside world.

Code re-use

If an object already exists (perhaps written by another software developer), you can use that object in your program. This allows specialists to implement/test/debug complex, task-specific objects, which you can then trust to run in your own code.

Pluggability and debugging ease

If a particular object turns out to be problematic, you can simply remove it from your application and plug in a different object as its replacement. This is analogous to fixing mechanical problems in the real world. If a bolt breaks, you replace it, not

class

the blueprint from which individual objects are created.

top-down programming

the concept of dividing a complex program into a hierarchy of program modules

But as time went on, people realized that the design of the what for a program was at least as important as the design of subroutines and control structures?

data structures

bottom-up design

A method of program refinement that starts with individual modules and builds them up into a complete program.

module

a component of a larger system that interacts with the rest of the system in a simple, well-defined, straightforward manner.

information hiding

a condition in which the user of a module does not know the details of how it is implemented, and the implementer of a module does not know the details of how it is used

state

(the data it contains

messages

calls to its subroutines

subroutines

In problem solving, specific procedures for solving familiar, well-defined problems

polymorphism.

Giving an action one name that is shared up and down a class hierarchy. Each class in the hierarchy implements the action in a way appropriate to itself.

Inheritance

is the capability of a class to use the properties and methods of another class while adding its own functionality.

structured programming

A method of programming which follows rules about selection, sequence, and iteration control structures. mostly used in 70's and 80's

a component of a larger system that interacts with the rest of the system in a simple, well-defined, straightforward manner

A module

The client can use a method without knowing how it is implemented. The details of the implementation are encapsulated in the method and hidden from the client who invokes the method. This is known as __________.

information hiding

The central concept of object-oriented programming is the

object

polymorphism.

Giving an action one name that is shared up and down a class hierarchy. Each class in the hierarchy implements the action in a way appropriate to itself.,

The ability to associate multiple meanings to one function name using dynamic binding is called _________.

polymorphism

Objects that contain the same type of data and that respond to the same messages in the same way belong to the same ----

class

Object-oriented programming allows classes to ---- commonly used state and behavior from other classes

inherit

how would you create a subclass from a superclass?

extends class inheriting from

set up a subclass MountainBike to go within Bicycle masterclass

class MountainBike extends Bicycle

Inheritance

the capability of a class to use the properties and methods of another class while adding its own functionality.

The Object class is

the highest superclass (ie. root class) of Java.

Java uses the--- keyword to set the relationship between a parent class and a child class

extends

creating a new set of method statements for the same method signature (name, number of parameters and parameter types).

Overriding

When extending a class constructor you can reuse the superclass constructor and overridden superclass methods by using the reserved word

super

The reserved word --- is used to distinguish between the object's property and the passed in parameter.

this

methods with no body specification.

Abstract methods

does not allow objects of its prototype to be created

an abstract class

methods with the same name signature but either a different number of parameters or different types in the parameter list.

Overloaded methods

methods that are redefined within an inherited or subclass. They have the same signature and the subclass definition is used.

Overridden methods

Dynamic (or late) method binding

he ability of a program to resolve references to subclass methods at runtime

private String name;
private String address;
private String city;
private String state;
private String zipcode;
private double creditLimit;

Section 1 - instance variables/attributes
contain information that an object of this class will hold

public void setName(String n)
{
name = n;
}
public void setAddress(String addr)
{
address=addr;
}

Section 2 - setters are used to change
the values of the instance variables
holds methods

public String getName()
{
return name;
}
public String getAddress()
{
return address;
}

Section 3 - getters are used to get
the value of an instance variable
holds methods

behaviors associated with a
class.

methods

In object-oriented terms, an object usually has which two properties?

state and behavior

An object stores its state in a:

field

Hiding internal information and requiring all operations to be done through an object's methods is known as:

data encapsulation

A(n) ____ is like a blueprint from which individual ____ can be created.

class, objects

In object-oriented terms, my car is a(n) ____ of the class of objects known as cars.

instance

Given a car class, the ____ (such as speed) represents the object's state, and the ____ (such as changing gears) defines its interaction with the outside world.

field, method

Object-oriented programming allows classes to _____ commonly used data and operations from other classes.

inherit

Car can be a _____ of sedan, SUV, and truck, which are _____.

super class, sub class