Shared Flashcard Set

Details

CSC116 -Java -Midterm 2
based on lecture and Building Java Programs by Reges & Stepp
27
Computer Science
Not Applicable
10/29/2011

Additional Computer Science Flashcards

 


 

Cards

Term
Iteration
Definition
Requiring you to do the same thing over and over again
Term
Three Types of Loops
Definition
while, do-while, for
do{
}
while();
Term
While Loops
Definition
used when we want to do the same thing over and over, but we do not know how many times if at all

while(){
}
Term
Infinite Loop
Definition
Loop cycles forever until you force the program to exit
Term
do-while loop
Definition
Similar to a while loop, except the loop will be executed at least one time no matter what the condition evaluates to
Term
for loop
Definition
Used when you know exactly how many times you want to execute a chunk of code

for(int i; boolean condition; i++)
Term
continue
Definition
stops the current iteration of a loop immediately; it stops executing code within the loop and immediately does whatever happesn when you reach the } of the loop
Term
nested loop
Definition
loop inside of a loop
Term
Class
Definition
An abstract representation of something
Term
Object
Definition
A specific instance of a class
Term
static
Definition
Staic applied to all methods and class variables tells java that we want to associate the methods and variables with the class itself

Not applying the keyword static tells Java that we want to associate the methods and variables with the instances of the class (objects) and not the class itself.
Term
attributes
Definition
Instance variables, when being referred to in a class/object context
Term
constructor
Definition
a special method that is executed automatically when an object is created. Constructors can never return anything. The main purpose is to give the object's instance variables an initial value. Can only be called when the object is created.

public (){
}
Term
constructor
Definition
a special method that is executed automatically when an object is created. Constructors can never return anything. The main purpose is to give the object's instance variables an initial value. Can only be called when the object is created.

public (){
}
Term
this
Definition
tells java that we want to use an instance variable instead of a local variable by righting this.variableName
Term
toString
Definition
method that allows us to create a text based representation of the Object and return it.

public String toString(){
}
Term
package
Definition
a collection of classes that all have something in common. Packages provide access protection and name space management
Term
import statments
Definition
import location.nameoffile

i.e. import java.io.FileWriter;
import java.io.*;
Term
try block
Definition
When we write code that could fail due to external conditions, we must write that code in a try block
Term
catch block
Definition
all try blocks must be followed immediately by a catch block, which is a chunk of code that will be executed if something goes wrong in the try block.

catch(IOException e)
{
}
Term
FileWriter
Definition
class that handles opening a file

FileWriter fw = new FileWriter("example.txt");

must close once you're done writing

fw.close();
Term
PrintWriter
Definition
class that handles writing to the file

PrintWriter pw = new PrintWriter(fw);

print to the file:

pw.println("hello");
Term
immutable
Definition
Once a String is created, it can not be changed.
Term
substring
Definition
String within a string
Term
format
Definition
Static method that accepts a set of arguments: a String called the "format String", and any variables/values you wish it to contain. It then returns a brand new String that contains a String that is formatted per your specifications.
Term
array
Definition
a structure that can keep track of large amounts of data under a single variable name; but be of all the same type

int array[] = new int[x];
Term
2D array
Definition
int[][] array = new int[x][y];
Supporting users have an ad free experience!