1/48
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
Class
A programmer-defined blueprint from which objects are created, defining state and behavior.
Object
A specific instance of a class representing a real entity with a specific state.
Instance
Another term for object; involves creating an object by instantiating a class.
Encapsulation
Bundling data and methods within a class and restricting access to its inner workings.
Visibility Modifier
Keywords in Java that define how accessible a component is.
Private
Modifier that makes a variable or method visible only within its own class.
Public
Modifier that allows visibility of a class member to all other classes.
Instance Variables
Fields that store the state of an object, declared within a class but outside any method.
Default Values
Automatic values assigned by Java if instance variables are not explicitly initialized.
Constructor
A special method used to initialize a newly created object.
No-Argument Constructor
Constructor that sets fields to generic default values.
Parameterized Constructor
Constructor that accepts arguments to set instance variables to specific values.
Constructor Overloading
Having multiple constructors in a class with the same name but different parameter lists.
Accessor Method (Getter)
Public method that retrieves the value of a private instance variable.
Mutator Method (Setter)
Public method that modifies the value of a private instance variable.
Variable Scope
The region of code where a variable is accessible.
Instance Scope
Scope of variables declared in a class and accessible by all methods in that class.
Local Scope
Scope of variables declared inside a method, accessible only within that method.
this Keyword
Reference to the current object, used to resolve naming conflicts.
Variable Shadowing
When a local variable has the same name as an instance variable, overshadowing it.
Precondition
Condition that must be true before a method is called for it to operate correctly.
Postcondition
Condition that holds true after a method has completed execution.
toString Method
A method that provides a readable string representation of an object.
Static Variable
Variable belonging to the class that is shared among all instances.
Instance Variable vs. Static Variable
Instance variables have their own copy per object; static variables are shared.
Void Constructor Error
Mistake of adding 'void' to a constructor, making it a regular method instead.
Public Fields Mistake
The error of having public fields that violate encapsulation principles.
Shadowing Logic Error
Error caused by confusion due to parameter and instance variable name clashing.
Uninitialized Variables Mistake
Error from using a local variable without initializing it.
Return Type Mismatch Error
Mistake of having a method return type that does not match the returned variable type.
Mnemonic P.I.E.
A way to remember aspects of Object-Oriented design: Polymorphism, Inheritance, Encapsulation.
Class Anatomy Structure
Structure includes instance variables, constructors, and methods.
Constructor Naming Rule
The constructor name must match the class name exactly.
Constructor Return Type Rule
Constructors do not have a return type, not even 'void'.
Method Decomposition
Breaking down methods into manageable parts following pre and post conditions.
GPA Validation Logic
Make sure the new GPA is within the range of 0.0 to 4.0 before assigning.
Accessing Private Variables
Use public accessor methods to interact with private variables.
Understanding Constructors
Constructors are invoked automatically when 'new' keyword is used.
Object Instantiation
The process of creating an object based on a class.
Multiple Constructors
Using different parameter types or counts to define multiple constructors in one class.
Instance Variables Scope
Always accessible by all methods of the class in which they are declared.
Default Values for Non-Initiated Variables
Default assignment happens: int=0, double=0.0, boolean=false, objects=null.
Java's Object Class
Every class in Java is derived from the generic Object class.
Mutable Object
An object whose state can be changed after it is created.
Immutable Object
An object whose state cannot be modified after it is created.
Abstract Class
A class that cannot be instantiated and often contains abstract methods.
Interface
A contract that defines methods which implementing classes must provide.
Inheritance
A mechanism to derive a new class from an existing class, inheriting fields and methods.
Polymorphism
Allowing methods to do different things based on the object it is acting upon.