What is an object in Java?
An object is a distinct entity created at runtime that combines state, behavior, and identity.
Study 7 Objects and Classes with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
What is an object in Java?
An object is a distinct entity created at runtime that combines state, behavior, and identity.
What is a class in Java?
A class is a blueprint and reference type that defines the data and operations its objects can have.
What three properties characterize an object?
State is an object's current information, behavior is what it can do, and identity makes it a distinct object.
What is a field?
A field is a variable declared inside a class that stores information associated with an object or the class.
How do instance and static fields differ?
An instance field has a separate value in each object; a static field has one shared value associated with the class.
What does encapsulation accomplish?
Encapsulation protects internal state by restricting direct access and exposing controlled public methods that enforce valid operations.
What is a method?
A method is a named block of code in a class that performs an action, changes state, or returns information.
What does a Java constructor do?
A constructor initializes a new object's fields. It has the class name, no return type, and runs when `new` creates the object.
What happens in `BankAccount account = new BankAccount(...);`?
`BankAccount account` declares a reference variable; `new BankAccount(...)` creates an object; `=` stores that object's reference in the variable.
What does `this` refer to in Java?
Inside an instance method or constructor, `this` refers to the current object.
What is constructor overloading?
Constructor overloading means defining multiple constructors in one class with different parameter lists.
What does `null` mean for a class-type variable?
`null` means a class-type variable refers to no object. Calling a method through it causes a `NullPointerException` at runtime.