Barron's: AP Computer Science A: Chapter 3: Classes and Objects

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

actual parameters

(aka arguments) parameters supplied by method calls in a client program

static method

(aka class method) performs an operator for the whole class → cannot call instance variates or methods since there is no class → used to manipulate static variables → invoked with the class name with the dot operator

null pointer

(aka null reference) an uninitialized object variable → can test if variables are null or set them to null → trying to use, will produce a NullPointerException

reference data type

Strong, Random, int[], etc. refer to the address in memory where an object is stored

explicit parameter

a parameter of a method other than the object on which the method is invoked; parameters passed in the parameter list

class

a software blueprint for implementing objects of a given type

object

a thing created and manipulated by a program; it corresponds to some real world object that is being represented by the program → has a state and behaviors → an instance of a class

method headers

access specifier return type method name parameter list

accessor method

accesses a class object without altering the object; returns some information about the object

this

as a parameter, will call the implicit parameter with a dot operator, can be used to call instance variables instead of explicit parameters with the same name

mutator method

changes the state of an object by modifying at least one of its instance variables

encapsulation

combining an object's data and method into a single unit (a class)

fail to initialize local variables

compile-time error

driver program

contains a <<main( )>> method used to test programs → all methods in the class including <<main( )>> must be static

static variable

contains a value (that can be changed) that is shared by all instances of the class; indicates that there is a single value of the variable that applies to the whole class, rather than a new instance for each object of the class → keep track of statistics for objects of the class → accumulate a total → provide a new identity number for each new object of the class

static final variables

contains a value (that cannot be changed) that is shared by all instances of the class

constructor

creates an object of the class → same name as the class → no return type

state

decided by data fields (aka instance variables)

primitive data types

double, int, char, boolean, etc. each has its own memory slot that stores the actual value

default constructor

has no arguments; provides reasonable initial values for an object

aliasing

having multiple references to the same object

dot operator

indicates that a method is in a certain class of an object

___ take precedence over ___ with the same name

local variables take precedence over instance variables with the same name

public methods

methods accessible to all client programs

instance methods

operate on individual objects of a class

passing primitive types as parameters

parameters are passed by value so *any changes made to the parameter will not affect the values of the arguments in the calling program* since a new memory slot is created for each parameter

formal parameters

placeholders for values in the method signature

object reference

representing an object as a variable store the addresses of their respective objects *NOT* the objects themselves

data hiding

restriction of access of data → using the key word <<private>>

new

returns the address of this newly constructed object

public

signals that the class is usable by all client programs

void

signals the method does not return a value

passing objects as parameters

the address (reference) is copied into memory, so although the method cannot replace the object, it can change the object's state → use the assignment operator and a method that returns an address to replace an object

fail to initialize instance variables

the compiler produces reasonable default values (0, 0.0, false, or null)

method signature

the method's name and a list of the parameter types

implicit parameter

the object of a method

scope

the region in which that variable or method is visible and can be accessed → instance and static variables and methods' scope is the entire class → local variables' scope is the method (or block) they are in

overloading methods

two or more methods in the same class that have the same name but different parameter lists → dependent on the method signature → the return type of the method is irrelevant so you cannot have two methods with the same signature but different return types → having more than one constructor


Set pelajaran terkait

Gross Anatomy I Test 1 (Previous tests)

View Set

Type II Diabetes - Pearson Questions

View Set

Ch. 6 - Database Design: Relationships

View Set

Christian Art, Architecture and Music

View Set

Sports Marketing Exam 3 Old Test

View Set