6 Conditions and Operators
Oracle Academy Section
Section 5: Conditional Programming
Lesson 1: Boolean Expressions and if/else Constructs
Lesson 2: Understanding Conditional Execution
Lesson 3: switch Statement
Section 5 Quiz
Java Foundations Certification Exam Topics
Using Decision Statements
Use the decision making statement (if-then and if-then-else)
Use the switch statement
Compare how == differs between primitives and objects
Compare two String objects by using the compareTo and equals methods
Working with Java Operators
Use basic arithmetic operators to manipulate data including +, -, *, /, and %
Use the increment and decrement operators
Use relational operators including ==, !=, >, >=, <, and <=
Use arithmetic assignment operators
Use conditional operators including &&, ||, and ?
Describe the operator precedence and use of parenthesis
Key Resources
Java Tutorials:
Udemy
Bucky's Room
Math Operators (5:29) int, operations on ints always result in ints, + - * / %
Increment Operators (5:08) ++, pre vs post. --, +=
Supplemental Resources
Bucky's Room
Building a Basic Calculator (7:12) could declare variables on same line (but not good style), nextDouble(), +, unexplained extra decimal places in answer
Language Companion Ch 2 IPO, data types, operators
Programmr:
Codecademy - Conditionals and Control Flow
Most Important Concepts / Code
+ will add if there are numbers on both sides.
+ will concatenate if there is a String on at least one side.
Each data type is also a class that contains methods for doing operations with the types like Double.intValue
Equality and relational operators: determine if one operand is greater than, less than, equal to, or not equal to another operand. Use == for equal to.
Conditional (logical) operators: && and ||
You cannot use == with strings.
Use a trailing else or default case to handle all possible cases.
if (testscore >= 90) {
grade = 'A';
} else if (testscore >= 80) {
grade = 'B';
} else if (testscore >= 70) {
grade = 'C';
} else if (testscore >= 60) {
grade = 'D';
} else {
grade = 'F';
}
System.out.println("Grade = " + grade);
int value1 = 1;
int value2 = 2;
if((value1 == 1) && (value2 == 2))
System.out.println("value1 is 1 AND value2 is 2");
if((value1 == 1) || (value2 == 1))
System.out.println("value1 is 1 OR value2 is 1");
Hour 1
Quiz and Concepts Review
+=
Integer division
Integer class (MIN_VALUE)
Unary operators
prefix vs. postfix
How to type if
Importance of curly braces
Importance of break
Example: tv models
Testing & Debugging Techniques
Test output
Breakpoints
Joke: Grocery
Meme: Count to Ten
Make a class
Plus Delta
Hour 2
Relational and Conditional
Trailing else / Default case
Equality vs. Assignment
Flowcharts - Logic Ch 4
Make Integration project menu driven - Logic Ch 11