Java OOP Vocabulary Flashcards (Lectures 3.1–3.7)

0.0(0)
studied byStudied by 0 people
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/37

flashcard set

Earn XP

Description and Tags

Vocabulary flashcards covering key object-oriented programming concepts from the lecture notes.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

38 Terms

1
New cards

Object

A value that combines data and the code that operates on that data; created from a class and represents an instance.

2
New cards

Class

A blueprint describing the data (fields) and behavior (methods) that all objects of that kind have.

3
New cards

Instance

A concrete object created from a class.

4
New cards

Static

A class-level member that belongs to the class itself, not to any specific object; can be accessed without an instance.

5
New cards

Method

A block of code defined in a class (or object) that can be called with parameters to perform actions or return a value.

6
New cards

Parameter

An input variable declared in a method signature; values provided when the method is called.

7
New cards

Return type

The type of value a method returns; use void if the method returns nothing.

8
New cards

void

A return type indicating the method does not return a value.

9
New cards

Public

An access modifier that makes a class, method, or field accessible from other code.

10
New cards

Private

An access modifier that restricts access to within the declaring class.

11
New cards

this

A keyword that refers to the current object inside an instance method.

12
New cards

Constructor

A special method that initializes a new object; has the same name as the class and no return type.

13
New cards

new

Operator that creates a new object and allocates memory for it.

14
New cards

Encapsulation

Bundling data and the code that operates on it inside a class and protecting data from invalid changes.

15
New cards

Abstraction

Hiding complex implementation details behind a simple interface.

16
New cards

Invariant

A rule that must always hold true for an object’s state (e.g., health must be >= 0).

17
New cards

getBalance

An accessor method in BankAccount that returns the current balance.

18
New cards

deposit

A method to add funds to an account; often returns a boolean indicating success.

19
New cards

withdraw

A method to remove funds from an account; may enforce rules and return a boolean.

20
New cards

BankAccount

An example class demonstrating encapsulation with private fields like balance and methods to manage money.

21
New cards

Player

A class used to demonstrate encapsulation; tracks stats like health and gold and provides methods to modify them.

22
New cards

health

A data field representing a Player’s vitality.

23
New cards

gold

A data field representing a Player’s currency.

24
New cards

takeDamage

A method that reduces health by an amount, ensuring health does not go below zero.

25
New cards

heal

A method that increases health by an amount, often guarded to enforce rules.

26
New cards

this.health

Accessing the current object’s health field; demonstrates use of this to disambiguate.

27
New cards

getHealth

Accessor method that returns a Player’s health.

28
New cards

setHealth

Mutator method that assigns a new health value while enforcing constraints like max health.

29
New cards

Area damage (wrong vs. right)

Wrong: pass primitive health values (copies) to modify; Right: pass Player references so the actual objects are modified.

30
New cards

Reference Type

Objects stored as references; copying the reference copies the address, not the object.

31
New cards

Primitive Type

Basic values stored directly (e.g., int, double); copying creates independent copies.

32
New cards

pass-by-value

Java passes a copy of the value; for primitives this is a new value, for references it’s a copy of the reference.

33
New cards

Locker analogy

Primitives are like sticky notes (independent copies); objects are like lockers (shared references).

34
New cards

Constructor invocation steps

new allocates memory, default values are set, constructor runs to initialize, and a reference to the new object is returned.

35
New cards

Encapsulation example (private fields)

Private data cannot be accessed directly; public methods control how data is changed.

36
New cards

Abstraction example

Hide complex logic behind simple method calls like heal or orderCheeseburger.

37
New cards

Polymorphism

Ability to treat different classes (e.g., Player, Monster, Building) the same when applying certain operations (to be explored later).

38
New cards

Inheritance

A mechanism for sharing code by creating a subclass that reuses behavior (to be explored later).