Classes and Objects

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

object state

a book object would have title, author, whetehr its on a shelf

object

a thing that is being created or manipulated by the program separate from concrete details of programming language, real world single instance of a class

method header (non-constructor)

access specifier, return type, method name, parameter list

public methods

accessible to all client programs clients are not privy to the class implementation and cannot access private instance variables or private methods

methods

behaviors exhibited by the object operations that manipulate the object

object behavior

book object could have the behavior of going out of print

parameter passing

by value primitive- method call allocates new memory for each parameter objects- passed by address which is copied, not the actual values

static final variables (constants)

cannot be changed, often public can be used in client methods static, single value

mutator method

change the state of an object, modifies at least one of instant variables

encapsulation

combining an objects data and methods into a single unit

constructor

creates an object of the class always same name as the class, no return type default constructor- no arguments

local variable

defined within a method, exists only within the block {}

primitive data type

double, int, char,boolean

new

every time you instantiate an object, returns the address of the object

. (dot operator)

indicates a method is part of a class to which the specific instance belongs

this

intance method always called for a particular object, "this" object is an implicit parameter for the method

data fields/instance variable

maintain the current state of an object

formal parameters (dummy)

method header, placeholders for the actual parameters

main() method

must always be static, all the methods in the class of the main method must be static

reference data type

object

instance method

operate on individual objects of a class

static method (also class method)

performs an operation on an entire class

primitive v reference

primitive- stored by value reference- stored by address

private

private methods and variables in a class can be accessed only by methods of that class

information hiding

using the keyword private

static variable (class variable)

value shared by all instances of the class, memory allocation only happens once

block

{}, when a block is exited, the memory for a local variable is automatically recycled

implicit parameter

?

object oriented programming

represent object as variable in a program, a variable that represents an object in java is called an object reference

accessor method

returns info on object

class

software blueprint for implementing objects of a given type

object variables

store the addresses of the respective objects, not the objects themselves

actual parameters (arguments)

supplied by the method call in the client

overloaded methods

two or more methods in the same class that have the same name but different parameter lists

aliasing

two references for the same object

null

uninitialized object uninitialized object is called null reference or null pointer

default value for primitives

0 for numbers, false for booleans

explicit parameter

?

"public" preceding class declaration

usable by all client programs not public, only used by classes in its own package all classes in AP java subset, all classes public

scope

region in which that variable can be accessed instance and static variables and methods of a class belong only to that classes scope


Ensembles d'études connexes

Network+ Ch.6: Wireless Networking

View Set

US History Chapter 5 Practice Quiz

View Set

Accounting Chapter 13, Chapter 13: Current Liabilities and Contingencies

View Set