Unit 5: Writing Classes Flashcards
Class
A blueprint or template for creating objects in object-oriented programming. It defines the properties and behaviors that an object of that class will have.
Global Scope
Refers to the area outside of any blocks or functions where variables are defined. Variables declared in the global scope can be accessed from anywhere in the program.
Instance Variable
A variable that belongs to an object and holds unique data for each instance of the class. It is declared within a class but outside any method.
Local Scope
An area within a specific block or function where variables are defined and accessible. Variables declared inside this local scope cannot be accessed outside of it.
Methods
Functions defined within a class that perform specific tasks or actions when called upon by an object. They can manipulate data, interact with other objects, or return values.
Mutator Methods (Setters)
Methods in object-oriented programming that allow the modification of an object’s attributes or properties. They provide a way to update the values of private instance variables within a class.
Object
An instance of a class that represents a specific entity or thing in a program. It contains both data (attributes) and behavior (methods).
Private
In the context of programming, refers to a visibility modifier that restricts access to certain variables or methods within a class. It means that only other members of the same class can access those private elements.
public
An access modifier in Java that indicates unrestricted visibility for classes, methods, and variables. Public members can be accessed from any other class or package.
Scope
Refers to the visibility and accessibility of variables, functions, and objects within a program. It determines where in the code these entities can be accessed and used.
Static Methods
Methods that belong to the class itself, rather than an instance of the class. They can be called directly using the class name without creating an object of the class.
Static Variables
Variables that belong to the class itself, rather than an instance of the class. They are shared by all instances of the class and can be accessed without creating an object of the class.
this keyword
Refers to the current object within an instance method or constructor. It can be used to refer explicitly to instance variables or invoke other constructors within the same class.
Variables
Named storage locations in computer memory that hold values which can be changed during program execution.
Abstraction
The process of simplifying complex systems by focusing on essential features while hiding unnecessary details. It allows programmers to work with high-level concepts without worrying about implementation specifics.
Behaviors
Refer to the actions or operations that an object can perform. They are defined as methods within a class and allow objects to interact with each other and manipulate data.
Default Constructor
A special type of constructor that is automatically created by the compiler if no other constructors are defined in a class. It initializes the object’s instance variables with default values.
Encapsulation
Refers to the bundling of data and methods within a class, where the data is hidden from external access. It ensures that an object’s internal state remains consistent by controlling how it can be accessed or modified.
Get Method (Accessor)
A method used to retrieve the value of an object’s private instance variable. It provides read-only access to the data stored in the object.
Instance Variables
Variables declared within a class but outside any method. They hold unique values for each instance (object) of the class and define the state or characteristics of an object.
Overloading constructors
Refers to the ability to have multiple constructors in a class, each with a different set of parameters. This allows objects to be created with different initial states or configurations.
Parameterized Constructor
A special type of constructor that allows you to pass arguments when creating an object. It initializes the object’s instance variables with specific values based on those arguments.
Set Method (Mutator)
A method in object-oriented programming that allows the modification of an object’s attributes or properties. It is used to update the values of instance variables within an object.
Assignment
The act of giving a value to a variable in programming. It involves storing information into memory locations so it can be accessed and manipulated later.