1/232
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Classification
is the process of grouping objects together based on common characteristics.
In Java, this is achieved through the use of classes and interfaces.
Classes, interfaces
_____ and _____ can be used to classify objects based on their attributes and behaviors.
Interface
is a collection of abstract methods and constants that can be implemented by a class
Interface
defines a set of methods that a class implementing that interface must provide.
methods in an interface
do not have any implementation, but only the method signatures are defined.
inheritance
Hierarchical relationship of classesi is created using _____.
child class
can inherit properties and methods from a parent class, and can also add its own properties and methods.
hierarchy of classes
This creates a _____, where each child class can inherit from its parent class, and can also be inherited by other child classes.
Generalization
is the process of creating a more general class from a more specific class.
Generalization
This allows you to create a hierarchy of classes that share common properties and behavior.
Specialization
is the opposite of generalization
Specialization
it involves creating a more specific class from a more general class.
Specialization
This allows you to add additional properties and behavior to a more specific class without affecting the more general class.
Specialization
is the act of capturing differences among objects in a class and creating new distinct subclasses with the differences.
Specialization
In this way, we are specializing information about objects of the superclass into subclasses.
Classification
categorizing objects into a class.
Classification
A subclass is a specialized class of a superclass, and a superclass is a generalized class of a subclass.
Generalization
the act of capturing similarities between classes and defining the similarities in a new generalized class
Generalization
the classes then become subclasses of the generalized class.
Specialization
the act of capturing differences among objects in a class and creating new distinct subclasses with the differences.
message
is a method call from a message-sending object to a message-receiving object.
message-sending object
is a sender
message-receiving object
is a receiver.
object
responds to a message by executing one of its methods.
may have as many methods as required
arguments
Additional information, known as _____, may accompany a method call.
parameterization
Such _____ allows for added flexibility in message passing
set of methods
collectively defines the dynamic behavior of an object.
object identifier, method name, arguments
A message is composed of three components
object identifier
indicates the message receiver
method name
corresponding to a method of the receiver
Arguments
additional information required for the execution of the method
method
is a program module that contains a series of statements that carry out a task.
main() method
can execute additional methods, and those methods can execute others.
class
Any _____ can contain an unlimited number of methods, and each method can be called an unlimited number of times.
calling method or client method
invokes a called method.
public,
private,
protected,
default
4 access modifiers
Return type
is a method that returns a value of a specific type after performing some operation.
return type of the method
specifies the type of the value that the method returns.
method that does not have a return type
is a method that does not return a value
method that does not have a return type
These methods are typically used to perform some operation or modify the state of an object, but they do not return any value.
void
The return type of a method that does not return a value is specified as _____
return statement
A method ends when any of the following events takes place:
The method reaches a _____.
return statement
causes a method to end and the program’s logic to return to the calling method.
return statement
frequently sends a value back to the calling method.
method’s return type
is known more succinctly as a method’s type.
Method chaining
Any method might call any number of other methods.
Client
Refers to an object that requests some operation to be performed by another object.
Client
The _____sends a message (invokes a method) to another object, asking it to perform a specific task or provide some information.
Client
is typically responsible for making the initial request and for processing any results that are returned.
Server
Refers to the object that receives and processes the message sent by a client.
Server
contains the methods that can be invoked by clients.
These methods define the behavior of the _____ object.
Server
After receiving a message, the _____ object performs the necessary operations and may return a result to the client.
Method overloading
in Java is a feature that allows a class to have multiple methods with the same name but different parameters.
Method overloading
This is useful when you want to perform the same operation with different types of data or with different numbers of arguments.
Method overloading
The compiler chooses the correct method to call based on the arguments that are passed.
parameter identifiers
do not have to be different, but the parameter lists must satisfy one or both conditions
different numbers
The lists must have _____ of parameters.
parameter data types
The lists must have _____ in different orders
Constructor overloading
in Java is a feature that allows a class to have multiple constructors with the same name but different parameter lists.
Constructor overloading
This is useful when you want to create objects with different sets of initial values or with different ways of initializing the object's state.
Constructor overloading
The compiler chooses the correct constructor to call based on the arguments that are passed.
Reference
is a type of variable that stores a memory address, which is the location of an object in the computer's memory.
reference
When you create an object in Java, the JVM allocates memory for the object and returns a _____ to that memory location.
reference variable
can be used to access the data and methods of the object it refers to.
reference
When you pass a ____ to a method, the method can modify the state of the object, and the changes are visible outside the method.
constant field
is a variable whose value cannot be changed after it is initialized.
constant field
are commonly used for values that are known at compile-time and should not be modified during runtime.
final keyword
is used to declare a variable, method, or class that cannot be changed or overridden after it is initialized.
is-a relationship
is used to describe inheritance and class hierarchies.
is-a relationship
It represents a relationship between a more general, abstract class (superclass or base class) and a more specific, concrete class (subclass or derived class).
Creating objects by instantiating those classes.
Developing classes to run as standalone applications.
Object-oriented programming involves creating classes, which can serve two main purposes:
application class
is identified by having a public static void main(String[] args) method
public static void main(String[] args) method
serves as the entry point for the application
Classes that lack main() method
are typically meant to be used by other classes that serve as applications, promoting code modularity and reusability.
main() method
a Java application can only have one _____ with the specific header public static void main(String[] args).
Creating a Class
Assign name to class
Determine what data and methods will be part of class
Class header
Optional access modifier
Keyword class
Any legal identifier for the name of class
Uppercase camel casing (conventional identifier)
Uppercase camel
Any legal identifier for the name of class
_____ casing (conventional identifier)
Creating a Class
In Class Body
Declaring instance
Attributes represent Variable
Declaring variable inside a class called Instance variable
Instance variable
Declaring variable inside a class called _____
static field
Shared among all instances of the class.
static field
only one copy, and it is shared by all objects of the class.
nonstatic field
Belong to individual instances (objects) of the class.
nonstatic field
Each object has its own set of this
private field
provide highest level of security to a field means that no other classes can access the field’s values, and only methods of the same class are allowed to set, get, or otherwise use private variables.
information hiding
principle used in creating private access is sometimes called _____;
is an important component of object-oriented programs.
Instance methods
in Java are methods that belong to an instance of a class, rather than to the class itself.
Instance methods
They are defined within a class, and can access and modify the state of the instance variables of that class
Static method
can call a static method on the class itself, without creating an object of that class.
nonstatic method
access and modify instance-specific data and variables, and their behavior can vary from one object to another.
Access Modifier
Return type
Method name
Parameter
4 Components of creating instance method
Method Body
It is a part of the method declaration.
Method Body
It contains all the actions to be performed.
Method Body
It is enclosed within the pair of curly braces.
Mutator method,
Accessor method
2 Types of Instance Method
Mutator method
is a type of instance method that is used to set or modify the value of an object's instance variable.
Mutator method
It is also known as a "setter" method because it "sets" a new value for a variable.
Accessor method
is a type of instance method that is used to get the value of an object's instance variable.
Accessor method
It is also known as a "getter" method because it "gets" the current value of a variable.
Mutator method
Define the method within the class definition.
Specify the access modifier (public, private, or protected) and any other relevant modifiers.
Specify the return type of the method. It is usually void because it doesn't return anything.
Specify the method name, using a naming convention like setVariableName() to indicate that it is a ____ method.
Write the code for the method inside curly braces to set the new value for the variable.
Accessor method
Define the method within the class definition.
Specify the access modifier (public, private, or protected) and any other relevant modifiers.
Specify the return type of the method to match the data type of the variable you want to retrieve.
Specify the method name, using a naming convention like getVariableName() to indicate that it is an _____ method.
Write the code for the method inside curly braces to return the value of the variable.