Chapter 3

¡Supera tus tareas y exámenes ahora con Quizwiz!

lazy operator

&& and ||

short-circuit operator

&& and ||

Write an expression that returns a random integers between 0 and 9, inclusive.

(int)(Math.random() * 10)

fall-through behavior

. Once a case is matched, the statements starting from the matched case are executed until a break statement or the end of the switch statement is reached

What is (int)Math.random() * 10?

0

Assume age = 16; ticketPrice = age >= 16 ? 20 : 10; What is ticketPrice?

20

Boolean expression

A Boolean expression is an expression that evaluates to a Boolean value: true or false . We now introduce Boolean types and relational operators.

Boolean value

A Boolean expression is an expression that evaluates to a Boolean value: true or false . We now introduce Boolean types and relational operators.

Assume x is an integer. Write a simple expression that returns true if x is even or false if x is odd.

Assume x is an integer. Write a simple expression that returns true if x is even or false if x is odd.

dangling else ambiguity

However, the else clause actually matches the second if clause. This situation is known as the dangling else ambiguity.

operator associativity

If operators with the same precedence are next to each other, their associativity determines the order of evaluation. All binary operators except assignment operators are left associative. For example, since + and - are of the same precedence and are left associative, the expression

debugging

Logic errors are called bugs. The process of finding and correcting errors is called debugging.

boolean data type

The boolean data type declares a variable with the value either true or false.

conditional operator

The symbols ? and : appear together in a conditional expression. They form a conditional operator and also called a ternary operator because it uses three operands. It is the only ternary operator in Java.

What is !true?

false

What is false || false?

false

What is true && false?

false

flowchart

is a diagram that describes an algorithm or process, showing the steps as boxes of various kinds, and their order by connecting these with arrows.

What is !false?

true

What is true && true?

true

What is true || false?

true

selection statement

used for programming with alternative courses of actions. There are several types of selection statements: one-way if statements, two-way if-else statements, nested if statements, multi-way if-else statements, switch statements, and conditional expressions.


Conjuntos de estudio relacionados

states of matter - physical science

View Set

History Unit 3: The Rise of Totalitarianism/ World War II

View Set

prepU ch 15 Management of Patients with Oncologic Disorders

View Set

Combo with "555-CH 32: Cardiovascular System" and 1 other

View Set

Chapter 13 - FIN3403 - Return, Risk, and Security Market Line

View Set

ch. 52- Concepts of Care for Patients with Inflammatory Intestinal Disorders

View Set

Unit 5 Development and Cognition NUR 2261

View Set

Fair Debt Collection Practices Act

View Set