Advanced Java Programming
Terms in this set (153)
Definition of a type ; a plan or blueprint( i.e. Strings - defines anything that is a string)
A specific instance of a class or a thing that fulfills the definition that all other things of that definition fulfill (i.e. A specific string = specific instance)
Specifies the members of the objects
Attributes of a class
Actions class can complete
Can be public/private, static/non-static, and of a certain type(primitive/class)
Can be public/private, static/non-static, and have a variables with scope within it, and have a return type (primitive/class) returning only one thing.
Must be called by an instance of the class in which it resides
Can be called directly by choosing the name of the class and method name
Creating a constructor
Points to the address that holds the instance variables of the ____and gives access to the method of the class
r1 Instance, non-static, instance
_______ calls the method about because about is ______, and must be called by an _______ of the class it resides
Make up the _______
*return_type(void, primitive, class, single)
*name(verb, first lowercase letter)
*parameter_list(number and type of arguments to be passed
Declaring a Program
Returns variable, always public, Control access to the variable
Sets the value of the instance variable, always public, Controls access to CHANGE of variable
Methods that can only be called from the class in which it resides in.
No arguments are passed to it ; assigns every instance variable with a null value; should be overrided
Arguments are passed to it; Helps to construct an instance of the class
*Must always have the same name of the class they're in
*Never have a return type (not even void)
*If you have a non-default one you must have a default
*Should give a value to every instance variables
*Should be the 1st methods of the class
*STRONGLY recommended but not required
Type name = new Type();
The format of making a constructor.
Create the instance.
Only execute the time when the instance is created.
A class that is an sub part of another should have this at the first line; A call to the constructor of the parent class.
A ______ method may be called
A _______ method may only be called
A variable that is shared by all the instances of the class in which that variable is declared
Memory space is put in place not for one instance but for all instances. One change from an instance affects all instances
Returns the memory address of the instance that called the method
Returns a string of all the values of the instance variables of the instance that callled the method
public String toString()
The format for toString is: ________-
*Expects no arguments
*Should be overriden
All classes descend from the class ________ (1st generation)
toString is inherited from the class ______ through the generations
Compares values stored in instance variables of calling and passed instances of a class
*Returns a boolean
*Expects an argument
*Inherited from Object class
*Should be overriden in every class
public boolean equals(classType alias)
The format for equals is:________
Making your own versions of the toString and equals methods
Must be declared in this way:
public String toString();//no arguments passed
public boolean equals(ObjectType alias);//you must pass an object of the same type as the class in which it resides
Represents the object that called the method
Having 2 or more methods in the class with the same name ; _______ on the parameter list (number and type of arguments expected)
access, invocation, return type, alias of parameters
Cannot overload on:
Convert the type
If the arguments do not have an exact match with any of the overloaded methods, Java will try to _________________. Otherwise it will fail.
A special kind of object used to store data that all must be of the same type; Collection of items of the same type
Base_Type Array_Name = new Base_Type[Length];
Format for creating an array:
An integer expression that indicates an array element
Variables that have an integer expression in square brackets are called _______
The only public instance variable for an array
*contains number of elements in an array
*value cannot be changed
Arrays start _____ not ____ or other numbers
Reading values into the array
The function of this code:
System.out.println("Enter 7 temperatures:");
for (int index = 0;index < 7; index++)
temperature[index] = keyboard.nextDouble();
Displaying values entered into array
Function of code:
System.out.println("The 7 temperatures are:");
for (int index = 0; index < 7; index++)
System.out.print(temperature[index] + " ");
Declares an array of integers
last valid index
arrayName.length - 1 represents the ______ of an array
Allocates memory for array to hold length
Array_Name = new Base_Type[Length];
The type for the array is called the ___________
ArrayName[n] = 32 is The ____of indexed variable
Out of bounds
If an index expression evaluates to an integer outside of the possible integers it is said to be ____________
Java stores what part of the objects in an array?
Placing numbers in a bracket after the assignment operator ______ an array so that the length is set to the ______ that will hold the values.
____ initialization is better than ____ initialization.
does not, references
When an array of objects is created, Java _______ create instances of any of the _____________ must first be created to the object.
When base type of the array name is a class type and does not reference any object of the class.
An indexed variable can be used as a(n) __________ anywhere a variable of the array's base type can be used by a method.
cannot, change, state
A method _______ change the value of an indexed variable when it is a primitive type but can ________ the ________ when it is a class type.
base type, length
When you specify an array parameter, you give the _______ of the array, but you do not fix the ________ of the array.
(i.e. public static void showArray(char a)
A method can change the ______ of the ______ in an array argument
public static Return_Type Method_Name(Base_Type Param_Name)
The syntax for an argument to a method being an entire array:
square brackets, argument, method
Characteristics of Array Arguments
*No _______ are written when you pass an entire array as an argument to a method
*An array of any length can be used as a(n) _________ corresponding to an array parameter
*A ____________ can change the values in an array parameter
array, String, String
The parameter String args declares that args is an _______ whose base is ______ that takes an array of _______ values as an argument
invoked, array of strings, operating system
main is _____________ automatically and given a default __________ but can be added with additional ones to provide elements using the _________.
one memory address
All the contents of an array are stored in _______________--
memory address, indexes
When using = between arrays you assign the ______________ of one array to the other so they are the same array with different names. Use arrays with _________ to retain the arrays with the same values.
The _______ operator tests whether the arrays are stored in the same place in the computer's memory.
Array, Class, Reference
_____ types and _______ types are _______ typesThey both hold the memory addresses as opposed to the actual item named by the variable.
To have a method return a whole array, you specify the ___________ the same way you specify the type of an array parameter.
A ________ instance variable that has an array type can be _______ outside of its class, if a public method in the class returns the array.
retrieved, added to, erased
An array as a list can only be _________ from, ________, or completely _________
The method _________ adds a string to end of a list.
On the OneWayNoRepeatsList class you access the arrays using ___________ and _________ methods
To step through a list begin by
*__________ an _____ variable to the first position on the list
You should keep track of the __________ you have used out of the array's __________ to avoid meaningless values
Arranging a collection of items into a particular order in ascending or descending order.
Algorithm that rearranges the values of the array so that a is the smallest, a is the next smallest, and etc.
Interchange sorting algorithm
Any sorting algorithm that swaps or interchanges values
The class Arrays in java.util package has a static method, ____, in which if anArray is an array of either primitive values/objects, the statement:
sorts the elements into _______order
To sort only with the index first, and ending with the index last, you would write
Arrays.sort(anArray, _________, __________)
Sequential Search Algorithm
Algorithm that looks at the array elements from first to last to see whether the sought-after item is equal to any of the array elements
Sequential Search Algorithm
*Search ends when found or end is reached without finding element
*Can search an unsorted array
Two-dimensional array, row, column
Arrays that have two indices, [first index] denotes the ___, [second index] denotes the ______ (begin at 0)
(Displayed on paper as a ____ table)
Syntax represents: _____________
Arrays having more than one index
Arrays with n indices are said to be ___
A two-dimensional array would require _____ for loops to step through all the index variables, A three-dimensional would need ______, four-dimensional ____ and etc.
Declaring a Multidimensional array
Base_type...Array_Name = new Base_Type[Length_1]...[Length_n];
Use __________ instead of literals to define the number of rows and columns
A multidimensional array can also be a method parameter. (True/False)
Multidimensional array parameter
Syntax for a method with a _____
static Base_Type... Method_Name(Parameter_List)
arrays of arrays
The Java compiler represents a multidimensional as __________.
For a two-dimensional array b, the value of b.length is the number of ______, (integer in 1st bracket pair). The value of b[i].length is the number of _______ (integer in 2nd bracket pair)
An array in which different rows have different number of columns
A method whose definition can be used for testing but is not yet the final definition
Alllows you to use an existing class to define new classes
Allow you to specify the methods that a class must implement
Makes object behave as you expect them to and allows you to focus on the specifications of those behaviors
Allows you to define a very general class and them later define more specialized classes that add some new details to the existing general class
A class defined by adding instance variables and methods to an existing class
The derived class _______ the _________ which is called the __________ or ___________.
A relationship in between two classes in which the derived can be identified as the bass class.
Parent class; child class
Bass class is often called a ____________ and a derived class is called a _________
A parent of a parent of another class (or some # of "parent of" is often called the __________
If an __ relationship does not exist b/w two proposed classes, do not use inheritance to derive one class from the other but define an object of one class as an INSTANCE variable WITHIN the OTHER CLASS. This is called _____
You define a ______ by starting with another already defined class and adding/changing methods and instance variables.
__________ a method redefines it in a descendant class when the bass class has the same name, number, and types of parameters, and return type.
overriding; change;overrides; signature;return type
When ______ a method definition, you CANNOT _____ the return type of the method. When one method ______ another, both method must have the same __________ and _______
_______ gets a method used before with different parameter amount/type while _______ replaces a method's definition with the same name, return type, and parameter type.
A ___________ method CANNOT be overridden.
When a constructor calls a public method, a derived class could override that method. To avoid it declare such methods as _______/
Private instance variables
________ in a base class are not inherited by a derived class and CANNOT be referenced directly by name in a derived class.
_________ in a base class are not inherited by a derived class; they cannot be called directly by name from a derived class
______ methods should serve only as HELPING methods and should be limited to the class in which they are defined.
public final void specialMethod()
A entire class can be declared _____ so you cannot derive from it as a bass class other classes.
Although a derived class cannot access a private method in the base class, it can call a __________ that in turn calls a ____ method when both methods are in the base class.
danger of malicious programmers
The reason why private instance variables cannot be access in a derived class is because of the _________________ that creates a problem.
A derived class __________ inherit any constructors from the base class.
keyword that calls the constructor of the base class.
*Must be the FIRST action taken in a constructor definition
Without ______, a constructor invokes the default constructor in the base class instead of the proper constructor. (i.e. studentName = "No name yet" vs. studentName = initialName)
Method that calls a constructor of the same class
Using ______ as an object calls a base-class method
repeat the use of
You cannot ________ super to invoke an overridden method from some ancestor class other than a direct parent.
An object of a(n) __________ class can do the same things as an object of a(n) _________________ class.
ancestor type; ancestor
Because an object of a derived class has the types of all of its ____________, you can assign an object of a class to a variable of any ___________ type, but not the other way around.
If class A has an object of class B as an instance variable, the relationship between A and B is _______
Every class is derived from the "Eve" class, __________
will not work;overridden
The methods equals and toString inherited form "Object" ______ correctly for almost any class you define and need to be ______ with new definitions
The _______ operator can be used to check whether an object is of a particular type.
Object ______ Class_Name
Allows you to make changes to the method definition in the derived class and apply those changes to the base class(happens automatically in Java)
Dynamic binding; late binding
When the method associated with a class used to create an object is invoked
*The variable name/type does not matter
class; is not
When an overridden method is invoked, its action is the one defined in the _____ used to create the object using the new operator. It _____ determined by the type of the variable naming the object
Defining a suitable toString method for your classes allows you to use _________________ to output the toString of the class.
Associating many meanings to one method name through dynamic binding.
A program component that contains the headings for a number of public methods
*including public named constants
*comments describing the methods so a programmer will have the necessary info to use them
Syntax for beginning a(n)__________;
public interface Interface_Name
*Contains no instance variables
*No complete method definitions (no bodies)
*methods must be public
*can define any number of public named constants
*a reference type(can write a method that has a parameter of this type)
implements the interface
When a class defines a body for every method specified in an interface.
*Not needed to declare every method but can _______ of more than one interface
Implementing an interface
implements Interface_Name, Another_Interface_Name...etc
Implementing an interface is a way for a programmer to __________ that a class ______ certain methods.
Implementing an interface
1. Include the phrase
2. Define each method declared in the interface(s).
(i.e. public class Rectangle implements Measurable)
method; definition of the method
A variable's type determines what __________ names can be used, but the object the variable references determines which ___________ will be used.
You can define another interface that builds on or __________ the first one using a kind of ______.
Breaking down the task to be performed into substasks
Allows you to specify how one object compares to another in terms of when one should "come before" "come after" or "equal" the other
___________ method should return:
*negative number if calling object "comes before" the parameter other
*zero if the calling object "equal" the parameter other
*Positive number if the calling object "comes after" the parameter other
A(n) ______________ method must be overridden by any non_______ derived class and given a definition
*If a class has at least one ______ method the class must be declared to be ______
*has no body
*You cannot create objects of that class; can only be a bass class
YOU MIGHT ALSO LIKE...
Abstract Classes and Methods
CSC 220 Final
APCS Chapter 11 Vocab
Programming (Intro to Inheritance)
OTHER SETS BY THIS CREATOR
Gantt Chart Exercise 1
CircuitPython CRICKIT HAT API part 1 of 4
THIS SET IS OFTEN IN FOLDERS WITH...
Java Chapter 4
(3) Core Java APIs
Learning Java 2: Language Basics
1.1 Code.org IP Address and DNS