Study your flashcards anywhere!

Download the official Cram app for free >

  • Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

How to study your flashcards.

Right/Left arrow keys: Navigate between flashcards.right arrow keyleft arrow key

Up/Down arrow keys: Flip the card between the front and back.down keyup key

H key: Show hint (3rd side).h key

A key: Read text to speech.a key

image

Play button

image

Play button

image

Progress

1/25

Click to flip

25 Cards in this Set

  • Front
  • Back

Selection statements

statements that let you choose actions with alternative courses




if() {


}


else {


}

Boolean data type

declares a variable with the value either true or false

Comparison operators

< less than


<= less than or equal to


> greater than


>= greater than or equal to


== equal to


!= not equal to

Boolean variable

a variable that holds a boolean value




cab hold one of the two values: true or false




ex: boolean lightsOn = true;

One-way if statement

executes an action if and only if the condition is true

syntax for if statement

if (boolean-expression) {


statement(s);


}

Flowchart

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

if-else statements

decides the execution path based on whether the condition is true or false

syntax for if-else statement

if (boolean-expression) {


statement(s)-for-the-true-case;


}


else {


statement(s)-for-the-false-case;


}

Nested if statement

an if statement can be inside another if statement




no limit on depth of nesting

multi-way if statement

avoids deep indentation and makes the program easy to read

Logical operators

can be used to create a compound Boolean expression




! not


&& and


|| or


^ exclusive or

De Morgan's Law

!(condition1 && condition2) is the same as


!condition1 || !condition2


!(condition1 || condition2) is the same as


!condition1 && !condition2

Switch statement

executes statements based on the value of a variable or an expression

syntax for switch statements

switch (switch-expression) {


case value1: statement(s)1;


break;


case value2: statement(s)2;


break;


...


case valueN: statement(s)N;


break;


defeault: statement(s) - for - default;


}

Switch expression must yield

a value of char, byte, short, int, or string type and must always be enclosed in parentheses

the value1... and valueN must

have the same data type as the value of the switch-expression

Break statement

immediately ends the switch statement

default case

can be used to perform actions when none of the specified cases matches the switch expression

executing a single statement at a time

the debugger allows you to execute one statement at a time so that you can see the effect of each statment

tracing into or stepping over a method

if a method is being executed, you can ask the debugger to enter the method and execute one statement at a time in the method, or you can ask it to step over the entire method




you should step over the entire method if you know that the method works

setting breakpoints

you can also set a breakpoint at a specific statement




your program pauses when it reaches a breakpoint




you can set as many breakpoints as you want




breakpoints are particularly useful when you know where your programming error starts




you can et a breakpoint at that statement and have the program execute until it reaches the breakpoint

displaying variables

the debugger lets you select several variables and display their values




as you trace through a program, the content of a variable is continuously updated

displaying call stacks

the debugger lets you trace all of the method calls


this feature is helpful when you need to see a large picture of the program execution flow



modifying variables



some debuggers enable you to modify the value of the variable when debugging




this is convenient when you want to test a program with different samples but do not want to leave the debugger