CSCE 111

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

nested loops

- a loop that is inside another loop - necessary when a task performs a repetitive operation and that task itself must be repeated

while loop

- has two main parts: 1) a Boolean expression that is tested for a true or false value 2) a statement or block of statements that is repeated as long as the expression is true - pretest loop

++ and --

- operators that add and subtract one from their operands - can work in prefix and postfix mode

loop

- part of a program that repeats - control structure that causes a statement or group of statements to repeat

for loop

- pretest loop - this loop is ideal for performing a known number of iterations - count-controlled loop

while loop, do-while loop, and for loop

Java's three looping control structures

throws IOException

PrintWriter objects are capable of throwing exceptions, which clause is written in the header

objects

Scanner object, Random object, and PrintWriter object are al examples of _______

println

The PrintWriter class's _______ method writes data to a file

inner, outer

______ loops complete their iterations before _______ loops do

running total

a sum of numbers that accumulates with each iteration of a loop

sentinel

a value that signals when the end of a list of values has been reached

copy

all arguments of the primitive data types are passed by value, meaning that only a ______ of an argument's value is passed into a parameter value

user controlled loop

allows user to decide the number of iterations

created in memory, class

before a specific type of object can be used by a program, that object has to be ___________, and before that you must have a _____ for that object

class

code that describes a particular type of object, specifies the data that an object can hold (fields) and the actions that an object can perform (methods)

method name

descriptive name for a method

data type

each parameter variable in a parameter list must have its ________ listed before its name

iteration

each repetition of a loop

instance

each time you create a Scanner object, you are creating a(n) _______ of the Scanner class

object

has two general capabilities: 1) it can store data (fields) 2) it can perform operations (methods)

same throws clause

if a method calls another method that has a throws clause in its header, then the calling method should have _________

return type

key word void, means the method is a void method and does not return a value

semicolons

method headers are never terminated with ________

@param tag

provides a description of each parameter

@return tag

provides a description of the return value

--

the decrement operator

if(file.exists())

this creates a File object representing the file

update expression

this expression executes at the end of each iteration, a statement that increments the loop's control variable

initialization expression

this expression is used to initialize a control variable to its starting value

while(inputFile.hasNext())

this expression reads lines from the file until no more are left

do-while loop

this loop always performs at least one iteration, even if the boolean expression is false to begin with

while loop

this looping control structure works like an if statement that executes over and over

continue statement

this statement causes a loop to stop its current iteration and begin the next one

break statement

this statement causes a loop to terminate early

count-controlled loop

this type of loop must possess three elements: 1) it must initialize a control variable to a starting value 2) it must test the control variable by comparing it to a max value 3) it must update the control variable during each iteration, usually done by incrementing the value

parameters

variables that receive argument values that have been passed to a method

instance

when a program is running, it can use the class to create, in memory, as many objects of a specified type as needed - each object that is created from this class is called a(n) _________ of the class

throws an exception

when an unexpected event occurs in a Java program, it is said that the program _________

parenthesis

when passing a variable as an argument, write the variable name inside __________ of a method call

local variable

when this is declared inside a method, it is not accessible outside the method

value-returning method

when writing this type of method, you must include its data type in the method header public static int sum(int num1, int num2)

while loop

while(BooleanExpression) Statement;

appending to a file

writing new data to the end of the data that already exists in the file

local variable

you may use a parameter variable to initialize a _________, but they must be given a value first before they can be used

do-while loop

- posttest loop - its boolean expression is tested after each expression - inverted while loop - terminated with a semicolon

accumulator

- the variable used to keep the running total - initialized with a starting value of 0

Random class

- this class provided by Java is used to generate random numbers - part of the java.util package

methods

- used to break a complex program into small, manageable pieces - a collection of statements that perform a specific task

arguments

- values that are sent into a method - can pass contents of variables and values of expressions as these

infinite loop

- you can create this kind of loop by accidentally placing a semicolon after the first line of a while loop

do not, do

______ place semicolons at the end of while and for loops, but _____ place a semicolon at the end of do-while loops

hasNext

a Scanner class method that can be used to determine whether the file has more data that can be read

test expression

a boolean expression that controls the execution loop, as long as this expression is true, the body of the for loop will repeat

input file

a file that a program reads data from

output file

a file that a program writes data to, program stores output in the file

text file

a file that contains data that has been encoded as text, using a scheme such as unicode

binary file

a file that contains data that has not been converted to text

call statements

a method is executed by _________

executing

a method's local variables only exist while the method is ________, once the method is done doing this, the local variables are destroyed

scope

a parameter variable's _______ is the method in which the parameter is declared, no statement outside the method can access the parameter variable by its name

exception

a signal indicating that the program cannot continue until the unexpected event has been dealt with

object

a software component that exists in the computer's memory and performs a specific task

parameter variable

a special variable that holds a value being passed into a method

parenthesis

in while and do-while loops, you must close the boolean expressions in ________

method calls

method headers and return types are written in method headers, but never in __________

hierarchal

methods can be called in this type of layered fashion

PrintWriter

pass the name of a file you wish to open as a string to this class's constructor

nextLine method

the Scanner class's ______ method reads a line of input, and returns the line as a string

object's method

the actions that an object can perform

data type

the argument's _________ must be compatible with the parameter variable's ________

object's field

the data that an object can hold

++

the increment operator

method modifiers

the key words public and class

functional decomposition

the process of breaking down a problem into smaller pieces, instead of writing one long method that contains all of the statements necessary to solve a problem, small methods are written, which each solace a specific part of the problem

input validation

the process of inspecting data given to a program by the user and determining whether its valid

priming read

the read operation that takes place just before the loop

header and a body

the two parts needed to create a method

String objects

these objects are immutable in the Java language, meaning they cannot be changed

control variable

this controls the number of time the loop iterates

conditional loop

this type of loops executes as long as a particular condition exists

value-returning method

this type of method returns a value to the statement that called it ex: the Random class's nextInt method

void method

this type of method simply executes a group of statements and then terminates ex: System.out.println

write data to

to __________ a file, you create an instance of the PrintWriter class

methodName();

to call a method, you must write a call statement, which is formatted like __________

&& and ||

to connect multiple boolean expressions in the test expression use ________

Random rand = new Random();

to create an object from the Random class

append data to an existing file

to do this, you must first create an instance of the FileWriter class, pass two arguments to the FileWriter constructor: a string containing the name of the file and the Boolean value true

commas

to execute more that one statement in the initialization expression and the update expression you separate the statements by _______

String friendName = inputFile.nextLine();

to read strings from a file

semicolons

to separate the initialization, test, and update expressions in a for loop, place _______ in between them

import statement

to use classes that work with files, you will place a _________ near the top of your program

exists method

use the File class's ________ method to determine whether a file exists

FileWriter and Scanner

use these class's to read data from a file

PrintWriter and FileWriter

use these class's to write data to a file

cast operator

use this operator to convert a value manually to a lower-ranking data type

comments

you must always document a method by writing _______ that appear just before the method's definition, which provides a brief explanation of the method's purpose

return statement

you must have this statement in a value-returning method because is causes the method to end execution and return a value to the statement that called the method

throws IOException

you must write this clause in the header of any method that passes a File object reference to the Scanner class constructor

Scanner class

you use this class to read input from a file, to do this, pass a reference to a File object


Ensembles d'études connexes

4.3 Polynomial Division and Synthetic Division

View Set

Mathematics: Pre-Algebra: Chapter 6: Basic Algebra

View Set

ExamFX: Chapter 1 Quiz 1- General Insurance

View Set

Nurs 211 Chapter 3: Health, Wellness, and Health Disparities

View Set

Big Data and Internet of Things (IOT)

View Set