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.
Constructor
A special method within a class that is used to initialize objects of that class. It is called automatically when an object is created and helps set initial values for its attributes.
String
A sequence of characters, such as letters, numbers, and symbols, that is used to represent text in programming. It is often enclosed in quotation marks.
Mutable Object
An object whose state can be modified after it is created. In other words, you can change the values of its attributes or properties.
Object’s State
Refers to the set of values stored in its instance variables at any given time during program execution. It represents the current condition or snapshot of an object’s data.
Student
An individual who is enrolled in a school or educational institution and is actively pursuing knowledge and education.
Postconditions
Conditions or requirements that must hold true after a certain action or function has been executed. They define what should be expected as a result of running the code.
Preconditions
Conditions or requirements that must be met before a certain action or function can be executed. They ensure that the necessary conditions are in place for the code to run correctly.
Throw Statements
Used in Java to manually throw an exception. They allow you to create and throw your own custom exceptions or propagate existing ones.
Try-Catch
A programming construct used to handle exceptions or errors that may occur during runtime. The code within the “try” block is executed, and if an exception occurs, it is caught and handled in the “catch” block.
@Override
Annotation used in Java to indicate that a method in a subclass is intended to override a method with the same name in its superclass. It helps ensure that the method signature and return type are correct.
Accessor Methods
A type of method in object-oriented programming that allows the retrieval of the value of an object’s private data member. They provide read-only access to the internal state of an object.
Assignment Class
Refers to a class used to store values assigned to variables. It is commonly used in programming to hold and manipulate data.