Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
43 Cards in this Set
- Front
- Back
method call
|
command that sends the computer to another method
|
|
parameters
|
- statements that appear in the ( ) following the name of a method
|
|
formal parameters
|
appears in ( ) after the method name- identifies the name and type of variables used in the method
|
|
actual parameters
|
gives value to formal parameters
|
|
return
|
specifies the value to be returned by a method, a command that causes the method to end immediately
|
|
Top-down Design
|
Problem solving strategy that breaks down each step into smaller steps
|
|
Array
|
a big variable that combines multiple elements all having the same type and same name; we distinguish among the elements using their position in the array
|
|
Object
|
an instance of the class
|
|
New
|
keyword that initializes objects, new says an instance has been created
|
|
Public
|
can only be assigned to one class per program
|
|
Constructor
|
a method whose name is the same as the class, it is called automatically when a new instance of the class is created
|
|
where does the program begin?
|
the program will begin at which ever method is called main
|
|
2 reasons for methods
|
They shorten programs
They break large programs into bite size pieces |
|
What does it mean to call or invoke a method?
|
to make it go to another method
|
|
Paramters are passed by ______. what does that mean?
|
value. This means that the actual parameters are copied into parameters when a method is called
|
|
How do you declare an array?
|
type[]name;
a= new type[number of slots in the array] |
|
Code to determine the capacity of an array?
|
Arrayname.length
|
|
code to find the smallest value in an array?
|
Assume first array element is the smallest
Smallest= a[0] Use a for loop to compare each element to the smallest |
|
code to find the sum of the numbers in an array?
|
Total= 0
For loop adding each element in array to total |
|
3 steps to using a file
|
Open, Use, Close
|
|
code to open a file
|
scanner= name;
name=new scanner(new file(“name of file”) |
|
code to close a file
|
name.close
|
|
code to determine if there is more info in the file
|
name.hasnextline()
|
|
Problems with files
|
Must import file class:
import java.io.File; public static void main (String [] args) throws IOexception Must handle possible IO exceptions: import java.io.IOExceptions |
|
what type of design does structured programing use?
|
Uses top-down design
|
|
what are the basic building blocks for structured programming?
|
Methods are the basic building blocks for designing and writing programs
|
|
How are classes used in structured programming?
|
Classes are viewed as a convient way to way to combine multiple elements having different types
|
|
what type of design does object oriented programing use?
|
uses object oriented design
|
|
What are the basic building blocks in object oriented design?
|
classes are the basic building blocks
|
|
how are methods used in object oriented design?
|
methods are used to perform actions within a class
|
|
what is the focus of object oriented design?
|
focuses on noun- things they know and things they can do
|
|
how can a class be used with in other classes?
|
a class can be used as a variable type in other classes
|
|
instances can be passed as_____.
whenever an instance is changed in a method, it is_________. |
parameter.
it is changed in main - the reference is created and destroyed |
|
purpose of a constructor
|
to initialize variables in a class (with values rather than the default 0 and null) as soon as they are created
|
|
Constructors are _________(3)
|
always public, never static, and it has no return type
|
|
purpose of a toString
|
whenever an object is printed, this method returns info rather than reference
|
|
toString Format
|
public String toString()
return (“blah blah blah”) |
|
%s
|
place holder for string
|
|
%d
|
place holder for int
|
|
%f
|
place holder for float/ double
|
|
code to introduce formatted print statement
|
System.out.printf
|
|
code to justify right
|
% field width .number of decimal places type (justifies right)
|
|
code to justify left
|
%- field width .number of decimal places type (justifies left)
|