Computer Programming Ch. 4 and 6

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

overloading

Having more than one method with the same name but differ- ent parameters. When you invoke an overloaded method, Java knows which version to use by looking at the arguments you provide.

dead code

Part of a program that can never be executed, often because it appears after a return statement.

Boolean Methods

Predicate methods. Most common is inside conditional statements. Common to give names sounding like yes/no true/false questions. Return is boolean- every expression returned is a boolean expression

nesting

Putting a conditional statement inside one or both branches of another conditional statement.

recursion

The process of invoking the same method you are currently executing.

return value

The value provided as the result of a method invocation.

flag=true;

initilization

unary minus

1 operand (-x)

logical operators

!, &&, ||

arithmetic operators

*, /, %, +, -

overloading

2 methods in the same scope can have the same name only if they have different parameter lists ( different in number and type )

binary minus

2 operand (x-y)

assignment operator

=

comparison operator

==

Don't compare values of type double with

== or !=

conditional/relational operators

==, !=, >, < >=, <=

conditional

A block of statements that may or may not be executed depending on some condition. If statements allowing code to respond in different ways

base case

A condition that causes a recursive method not to make a recursive call.

void

A special return type that indicates a void method; that is, one that does not return a value.

boolean

A type of variable that can contain only the two values true and false.

flag

A variable (usually boolean) that records a condition or status infor mation.

chaining

A way of joining several conditional statements in sequence. Check for a number of related conditionals

logical operator

An operator that combines boolean values and produces boolean values. AKA arithmetic operators. Conditional, relational, and comparison.

conditional operator

An operator that compares two values and produces a boolean that indicates the relationship between the operands.

typecast

An operator that converts from one type to another. In Java it appears as a type name in parentheses, like (int).

modulus

An operator that works on integers and yields the remainder when one number is divided by another. In Java it is denoted with a percent sign(%). Returns remainder. Helpful determining if odd or even.

relational and logic operators return

Boolean result

scaffolding

Code that is used during program development but is not part of the final version.

5 characteristics of a variable

Data type, name, what value is stored, scope, life time

return type

The part of a method declaration that indicates what type of value the method returns

Leap of Faith

When you come to a method invocation instead of following the flow of execution, assuming the method works correctly

return statement

causes method to stop immediately. Think of the " go to jail" stop on monopoly. To check for data that might stop errors. Any code following it will not return.

double

data type of the value being returned

boolean flag;

declaration

condition

expression in parantheses

alternative execution

gives 2 paths to follow as result of an if statement. if/else

Incremental Development

identify what output the program needs to produce, then identify what input is required and what process needs to be applied to input to produce required output

if there is a return

no "else" is needed

life time

point where its declared until the end of the code block; when it's removed from memory

type conversion

whenever you try to "add" 2 expressions, if one of them is a String, Java converts the other to a String performing string concatenation. EX. System.out.print("The answer is" + x)

scope

where you can access the variable

relational operators

x==y x!=y x>y x<y x>=y x<=y


Ensembles d'études connexes

United States History to 1877 - Chapter 1

View Set

Financial Accounting Chapter 9 Review

View Set

Vocabulary Lesson 8: Damage and Deterioration

View Set

Georgia Pre-Licensing Insurance Study

View Set