Level 87 Level 89
Level 88

[Quiz] Methods


81 words 0 ignored

Ready to learn       Ready to review

Ignore words

Check the boxes below to ignore/unignore words, then click save at the bottom. Ignored words will never appear in any learning session.

All None

Ignore?
java.lang
What package is the String class in?
What does java.lang do?
defines commonly used classes (ex. System, Math, Object, String)
fields
And object stores it states in _______.
Constructors
procedures for constructing new object in class/ initializing its fields
Methods
It is basically a behavior. A class can contain many methods. It is in methods where the logics are written, data is manipulated and all the actions are executed.
data type
The kind of information a variable stores.
method's parameters
A method must match _______.
method does not return any value
What does the keyword void in a method header mean?
encapsulation (information hiding)
situation where class interacts with other classes only through constructors/ public methods
encapsulation
helps hide implementation behind an interface or API
same
Constructors and methods can call other public/ private methods of the _______ class.
public
Accessible by any class in the program.
fields, methods
What does a subclass inherit from a superclass?
flowcharts
graphical representation of control flow
parallelogram
flowchart shape for input/ output
rectangle
flowchart shape for processing step
diamond
flowchart shape for decision
variables
used as a general term for things that store data in a program.
compactness
iterations/ recursions can be used to repeat same steps multiple times
generality
same one applies to any "size" task or any input values
abstractness
does not depend on specific computer language/ platform (though may depend on general computing model)
iterations
repeat same instructions multiple times; start with initial variable values (some change each cycle); supported by high-level programming languages
When do iterations stop?
when the tested condition becomes false
recursion
describes procedure for a particular task in terms of applying the same procedure to a similar but smaller task
base case
Must have a _______ when the task is so simple that no recursion is needed
smaller parameter value
A recursive method calls itself with what?
How does recursion work?
implemented like iterations but is hidden from the programmer
system stack
Recursion is assisted by what?
nested structures or branching processes
Recursion is especially useful for dealing with what?
Euclid's Algorithm
finds the GCF of two positive integers
list
an ordered collection (sometimes called a sequence); can contain duplicate elements; have precise control over where each element is inserted in the list and can be access elements by their integer index (position)
list traversal
start at the first element; while more elements remain, process the next one
sequential
type of search where the number of comparisons is proportional to the length of the list
binary
type of search involving "divide and conquer"; target value always compared with middle element of remaining search range
A method or a function.
What carries out a specific task within a class?
A function
What is an internal decomposition unit because it is not a stand-alone module, therefore must belong to a class?
What is local data?
Data declared within a function that is known only to that function.
When does local data exist?
Only during the execution of the function containing it.
When does a function start executing?
When it is called by another function.
Method invocation.
A function call is also known as a _______.
What are three general categories of functions?
Simple functions, value-returing functions, and functions with parameters.
What is a simple (void) function?
A function that does not return any value to the function that invoked it.
What are the attributes of a method?
Method name, purpose of the method, return type, number and types of parameters.
public/private in front, usually private
What is special about a field?
Format of variable
sometype someName; or ""=expression;
final variable
a variable thats value, once assigned, cannot change (initialized final variable is a constant)
yes, but may cause bugs
can you use thesame name for a field and local variable?
8 primitive data types
boolen, byte, char, double, float, int, long, short
primitive
these types do not have properties of objects
Char
Data type indicative of a single symbol
integer
public int cadence;
float, double
floating-point real number
String
The String class represents an immutable, e.g. cannot be changed, string of characters with its own methods.
special about strings (2)
double quotes for literal string, can use + operator
literal, symbolic
types of constants(2)
escape pair
back slash and single character
symbolic constant
initialized final fields
Does a constant have to be initialized right away
no its final value can be set in a constructor
Why use symbolic constants
simplifies program matinence, (can make changes to constant, will change throughout program), readibility, easier to change constant into variable
Symbolic constants (like variables) are declared...
with a particular data type and defined only within their scope
the class (all methods/constructors)
scope of field extends through
the scope of a local variable extends
from declaration to end of the block
field
A software object's state is stored in a
can you get true ratio with ints?
no you have to turn them into doubles
Truncate
Removing the decimal portion of a number when casting a double to an int.
how do you conver ints to doubles
cast operator, ex) double ratio = (double)a/b
add .5
what do you do to round to the nearest integer
compatible data types
cast operator applies only to
a += b
a = a + b
a++
a = a + 1 * incremented after use in expression
a--
a = a -1* incremented after use in expression
-A
a = a - 1* incremented before
when using + operator for string concatenation
at least one of the two operands must be a string
+= for concatenation
left operand must be string
turn value into string?
concatenate with empy string or call toString method
sequentially
Normal control flows _______ from one statement to the next during program execution.
alter the execution sequence of a program
What do calls to methods, iterative statements (loops), conditional (if-else) statements, switch statements, and exceptions have in common?
if statement
tells the program to choose and execute one fragment of code or another depending on some condition
switch statement
chooses a particular fragment of code out of several based on the value of a variable or expression
conditional branching
If-else control structure allows _______.
conditional jumps
special CPU instructions that support conditional branching; tests a certain condition and tells the CPU to "jump" to a specified instruction depending on the result of a test