CSA - Unit 2

studied byStudied by 2 people
0.0(0)
learn
LearnA personalized and smart learning plan
exam
Practice TestTake a test on your terms and definitions
spaced repetition
Spaced RepetitionScientifically backed study method
heart puzzle
Matching GameHow quick can you match all your cards?
flashcards
FlashcardsStudy terms and definitions

1 / 29

flashcard set

Earn XP

Description and Tags

send help

30 Terms

1

Objects

  • Something being created/ manipulated by the program

  • Characterized by it’s state and behavior

  • Instance of a class

New cards
2

Object Reference

  • A variable that represents an object

New cards
3

Class

  • Encapsulates data

  • An object is an instance of a class

New cards
4

Public class

  • Usable by all client programs (pieces of code outside the class)

    • All classes are public in AP Java subset

New cards
5

Public Methods

  • Accessible to all client programs

New cards
6

Private Methods/Variables

  • Can only be accessed by methods in the same class

New cards
7

Static Variable (Class Variable)

  • Memory allocation only happens once

    • Shared by ALL INSTANCES of the class

New cards
8

Static Final Variable (constant)

  • Cannot be changed

  • Public

  • Single value that applies to the whole class instead of a new instance for each object of the class

    • BankAccount.PENALTY for client

    • PENALTY in own class

New cards
9

Method Header

Public void Withdraw (String password, double amount)

Access Specifier | Return Type | Method Name | Parameter List

  • Access specifier = who has access

  • Void = method doesn’t return a value

    • Parameters are separated by commas, require data type

  • Implementation follows header and is enclosed by {}

New cards
10

Constructor

  • Method that creates an object of the class

    • Name is same as class, no return type

New cards
11

No-Argument Constructor

  • No parameters

    • Provides initial values for an object

New cards
12

Reference to an Object

  • Variable assigned values of the object

New cards
13

Constructor with parameters

  • Sets instance variables to values of those parameters

    • They can be changed in different references

New cards
14

Accessor Method

  • Public method that accesses a class object without altering it

    • .getBalance

New cards
15

Mutator Method

  • Changes state of an object by modifying at least one instance variable

New cards
16

Instance Methods

  • Perform operations on individual objects of a class

  • Constructors, accessors, mutators

New cards
17

Static Methods

  • Perform an operation for the entire class

  • Keyword Static in header

    • Can use a static variable in its code

New cards
18

Driver Class

  • Main() method is always static

    • Tests other classes

New cards
19

Method Overloading

  • 2 or more methods in the same class with the same name but different parameter lists

  • Distinguished by method SIGNATURE

    • Can’t have 2 methods with same signature but different return types, so return type is irrelevant

New cards
20

Scope

  • Region in which the variable/ method is visible and can be accessed

  • A class’s instance + static variables and methods belong to the class’s scope (enclosed by {})

    • DOT OPERATOR NOT NEEDED

New cards
21

Local Variable

  • Defined inside a method or statement

    • Scope is from declaration to end of its block

  • Precedence over instance variables with same name

New cards
22

Block

  • Piece of code enclosed by {}

New cards
23

This Keyword

  • Instance methods are called for a particular object, which is an IMPLICIT PARAMETER for the method

    • Referred to with keyword this

New cards
24

Reference Data Types

  • Objects and arrays

  • String, Random, int[], string [] [], Cat, etc

  • STORES MEMORY ADDRESSES

    • If object is changed, any references aliased to it will also change

New cards
25

Primitive Data Types

  • Double, int, char, boolean

    • STORES VALUE DIRECTLY

New cards
26

Null Reference

  • Uninitialized object variable

  • Null pointer

  • Doesn’t refer to an object

New cards
27

Formal Parameters

  • Placeholders for actual parameters

  • String acctPassword, Double amount

New cards
28

Actual Parameters

  • Actual values given to a method call

  • Match up with formal parameters

New cards
29

Primitive Types as Parameters

  • Changes made to parameters of method will not affect the values of the arguments in the calling program

  • Basically goes back to what it was before

  • Passed by value

New cards
30

Objects as Parameter

New cards
robot