WEBVTT

00:00.000 --> 00:05.000
Operators and expressions

00:05.000 --> 00:12.000
In this video we will understand, identify arithmetic, relational, and logical operators in Java.

00:12.000 --> 00:16.000
Apply operators in expressions for calculations and decisions.

00:16.000 --> 00:20.000
Understand precedence and associativity in expressions.

00:20.000 --> 00:24.000
Use operators in real life cases like discounts and trade.

00:24.000 --> 00:27.000
Welcome to Java programming.

00:27.000 --> 00:31.000
In this lesson, we'll learn about operators and expressions.

00:31.000 --> 00:36.000
Operators are symbols like plus minus, multiply, and divide.

00:36.000 --> 00:41.000
Expressions are combinations of values and operators that give results.

00:41.000 --> 00:45.000
For example, 5 plus 3 equals 8.

00:45.000 --> 00:53.000
Here, the symbol plus is the operator, and the part 5 plus 3 is the expression.

00:53.000 --> 00:56.000
Java has three main types of operators.

00:56.000 --> 01:00.000
These are arithmetic, relational, and logical operators.

01:00.000 --> 01:03.000
Arithmetic operators do basic math.

01:03.000 --> 01:05.000
5 plus 3 equals 8.

01:05.000 --> 01:07.000
7 minus 2 equals 5.

01:07.000 --> 01:10.000
4 times 2 equals 8.

01:10.000 --> 01:13.000
8 divided by 2 equals 4.

01:13.000 --> 01:18.000
Plus minus, multiply, and divide our arithmetic operators.

01:18.000 --> 01:21.000
Relational operators are used to compare values.

01:21.000 --> 01:25.000
For example, mark 75 passing marks 40.

01:25.000 --> 01:30.000
When we check, marks greater than passing marks, the result is true.

01:30.000 --> 01:34.000
Here, the greater than symbol is the relational operator.

01:34.000 --> 01:37.000
Logical operators combine conditions.

01:37.000 --> 01:42.000
For example, age greater than 18 and has a license gives true.

01:42.000 --> 01:45.000
Age greater than 18 or student gives true.

01:45.000 --> 01:48.000
Not age greater than 18 gives false.

01:48.000 --> 01:52.000
And, or and not our logical operators.

01:52.000 --> 01:56.000
Like in math, some operations come first.

01:56.000 --> 02:01.000
Multiplication happens before addition, but parentheses can change the order.

02:01.000 --> 02:06.000
This rule is called operator precedence.

02:06.000 --> 02:09.000
Let's see how operators work in real life.

02:09.000 --> 02:11.000
Imagine you're shopping.

02:11.000 --> 02:14.000
The price of an item is 1,000 rupees.

02:14.000 --> 02:18.000
A 10% discount is applied, so the price drops to 900.

02:18.000 --> 02:24.000
Then, a 5% tax is added, making the final price 945.

02:24.000 --> 02:29.000
In Java, we can write this calculation using arithmetic operators.

