Professional Documents
Culture Documents
Outline
●
Environment setup
●
Basic Syntax
●
Data types
●
Operations
●
Input & Output
●
Decision making
●
Loops
●
Methods
●
Output:
== (equal to) Checks if the values of two operands are equal or not,
if yes then condition becomes true.
!= (not equal to) Checks if the values of two operands are equal or not,
if values are not equal then condition becomes true.
> (greater than) Checks if the value of left operand is greater than the
value of right operand, if yes then condition becomes
true.Java ( ROBOTO Academy )
The Relational Operators
< (less than) Checks if the value of left operand is less than the value of
right operand, if yes then condition becomes true.
>= (greater than or Checks if the value of left operand is greater than or equal to
equal to) the value of right operand, if yes then condition becomes true
<= (less than or equal Checks if the value of left operand is less than or equal to the
to) value of right operand, if yes then condition becomes true.
&& (logical and) Called Logical AND operator. If both the operands are
non-zero, then the condition becomes true.
●
What is the final value of x after execution ?
●
x will be 50.
●
Because x was 10 so the if condition is true
x < 20 10 < 20
●
So will execute the statement x = 50;
●
What is the final value of x after execution ?
●
x will be 30.
●
Because x was 10 so the if condition is false
x > 20 10 > 20
●
So will execute else block of code which is x=30;
●
What is the final value of x after execution ?
●
x is 15.
●
Because x was 5 so the first if is true
●
The inner if is false because y is 10
●
Then the inner else is executed which is x = 15;
●
Guess what the output is.
●
What is the output ?
●
Although the condition x < 10 is not true as x
started with value 10 but the body executed as we
mentioned that the body executes at least once
●
This method takes 2 numbers and return the
sum of the two numbers.
●
How to call a method ?
●
Type the method’s name and give it the parameters it needs.
●
The method’s return value is now stored in the variable sum.
No return statement.