Flashcards
Selection Statements
Flashcards do conjunto (19)
- 1What are the 3 Selection Statements?1) If
2) If-Else
3) Switch - 2Operators Confusing the Equality Error(==) with the assignment operator (=) can cause _____error
- 3Logical Operators What do they enable?Testing of multiple conditions in the process of making a decision
- 4Logical Operators && What does this mean?AND
- 5Logical Operators || What does this mean?OR
- 6Logical Operators ?: What is this called? What does this mean?Ternary
Shorthand for if-then-else - 7If Statements If the statement is NOT true, what happens?It is skipped unless there is an else
- 8If Else Allows you to specify an action to perform when the condition is _____ and _____TRUE and FALSE
- 9If Else What is the conditional operator sign for If Else??:
- 10If Else Using a conditional operator, write a if else statement so that if a grade is over 50 then "Pass" is outputted, or else "Fail" if it is below 50syso(grade>= 50 ? "Pass" : "Fail");
- 11If Else Using a conditional operator, set the max int to be the greater value of two ints a==5 and b==6max = (a>b) ? a : b;
- 12Nested If-Else Statements It can be used to test _____ cases under the main if statement, what is the next condition?multiple
else if - 13Dangling Else Problem What is it?Not including curly brackets (braces{}) then the else will refer to the most immediate instance of If(one if inside another) rather than referring to the intended original If
JUST PUT YOUR CURLY BRACES IN AND YOU'LL BE FINE! - 14Braces While it is possible to exclude them if you only have one statement, it is recommended not to! Why not?1) Increases Code Readability
2) Reduces Logical Errors
3) Ease of Maintenance - 15Switch Statement Why leave the default until the end?There is no "break;" required then
- 16Switch Statement What is "fall-through"?If a "break;" is not employed after each condition then all statements after the matching case label will be executed
- 17Switch Statement Can you have multiple cases?Yes
- 18Switch Statement Can you have multiple conditions?Yes
- 19Switch Statements As of Java SE 7, you can use _____ in a Switch StatementsStrings
Informações
- Descrição
- Masters Programming I FlashCards sobre Selection Statements, criado por nhunsdale02 em 04-06-2014.
- Criado por
- nhunsdale02
- Visualizações
- 17
- Avaliação