Mastering Object-Oriented Design in Java

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

1/48

flashcard set

Earn XP

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

49 Terms

1
New cards

Class

A programmer-defined blueprint from which objects are created, defining state and behavior.

2
New cards

Object

A specific instance of a class representing a real entity with a specific state.

3
New cards

Instance

Another term for object; involves creating an object by instantiating a class.

4
New cards

Encapsulation

Bundling data and methods within a class and restricting access to its inner workings.

5
New cards

Visibility Modifier

Keywords in Java that define how accessible a component is.

6
New cards

Private

Modifier that makes a variable or method visible only within its own class.

7
New cards

Public

Modifier that allows visibility of a class member to all other classes.

8
New cards

Instance Variables

Fields that store the state of an object, declared within a class but outside any method.

9
New cards

Default Values

Automatic values assigned by Java if instance variables are not explicitly initialized.

10
New cards

Constructor

A special method used to initialize a newly created object.

11
New cards

No-Argument Constructor

Constructor that sets fields to generic default values.

12
New cards

Parameterized Constructor

Constructor that accepts arguments to set instance variables to specific values.

13
New cards

Constructor Overloading

Having multiple constructors in a class with the same name but different parameter lists.

14
New cards

Accessor Method (Getter)

Public method that retrieves the value of a private instance variable.

15
New cards

Mutator Method (Setter)

Public method that modifies the value of a private instance variable.

16
New cards

Variable Scope

The region of code where a variable is accessible.

17
New cards

Instance Scope

Scope of variables declared in a class and accessible by all methods in that class.

18
New cards

Local Scope

Scope of variables declared inside a method, accessible only within that method.

19
New cards

this Keyword

Reference to the current object, used to resolve naming conflicts.

20
New cards

Variable Shadowing

When a local variable has the same name as an instance variable, overshadowing it.

21
New cards

Precondition

Condition that must be true before a method is called for it to operate correctly.

22
New cards

Postcondition

Condition that holds true after a method has completed execution.

23
New cards

toString Method

A method that provides a readable string representation of an object.

24
New cards

Static Variable

Variable belonging to the class that is shared among all instances.

25
New cards

Instance Variable vs. Static Variable

Instance variables have their own copy per object; static variables are shared.

26
New cards

Void Constructor Error

Mistake of adding 'void' to a constructor, making it a regular method instead.

27
New cards

Public Fields Mistake

The error of having public fields that violate encapsulation principles.

28
New cards

Shadowing Logic Error

Error caused by confusion due to parameter and instance variable name clashing.

29
New cards

Uninitialized Variables Mistake

Error from using a local variable without initializing it.

30
New cards

Return Type Mismatch Error

Mistake of having a method return type that does not match the returned variable type.

31
New cards

Mnemonic P.I.E.

A way to remember aspects of Object-Oriented design: Polymorphism, Inheritance, Encapsulation.

32
New cards

Class Anatomy Structure

Structure includes instance variables, constructors, and methods.

33
New cards

Constructor Naming Rule

The constructor name must match the class name exactly.

34
New cards

Constructor Return Type Rule

Constructors do not have a return type, not even 'void'.

35
New cards

Method Decomposition

Breaking down methods into manageable parts following pre and post conditions.

36
New cards

GPA Validation Logic

Make sure the new GPA is within the range of 0.0 to 4.0 before assigning.

37
New cards

Accessing Private Variables

Use public accessor methods to interact with private variables.

38
New cards

Understanding Constructors

Constructors are invoked automatically when 'new' keyword is used.

39
New cards

Object Instantiation

The process of creating an object based on a class.

40
New cards

Multiple Constructors

Using different parameter types or counts to define multiple constructors in one class.

41
New cards

Instance Variables Scope

Always accessible by all methods of the class in which they are declared.

42
New cards

Default Values for Non-Initiated Variables

Default assignment happens: int=0, double=0.0, boolean=false, objects=null.

43
New cards

Java's Object Class

Every class in Java is derived from the generic Object class.

44
New cards

Mutable Object

An object whose state can be changed after it is created.

45
New cards

Immutable Object

An object whose state cannot be modified after it is created.

46
New cards

Abstract Class

A class that cannot be instantiated and often contains abstract methods.

47
New cards

Interface

A contract that defines methods which implementing classes must provide.

48
New cards

Inheritance

A mechanism to derive a new class from an existing class, inheriting fields and methods.

49
New cards

Polymorphism

Allowing methods to do different things based on the object it is acting upon.