Difference between revisions of "Java/C2/Relational-Operations/English-timed"
From Script | Spoken-Tutorial
PoojaMoolya (Talk | contribs) |
|||
(9 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{| border=1 | {| border=1 | ||
− | || ''Time''' | + | || '''Time''' |
|| '''Narration''' | || '''Narration''' | ||
+ | |||
|- | |- | ||
| 00:01 | | 00:01 | ||
− | | | + | | Welcome to the spoken tutorial on '''Relational Operators in Java'''. |
|- | |- | ||
| 00:07 | | 00:07 | ||
| In this tutorial, we will learn about the | | In this tutorial, we will learn about the | ||
− | |||
|- | |- | ||
| 00:09 | | 00:09 | ||
− | | | + | | ''' boolean data type''','''Relational operators '''and |
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
| 00:12 | | 00:12 | ||
− | | how to '''compare data '''using '''Relational operators.''' | + | | how to '''compare''' '''data''' using '''Relational operators.''' |
− | + | ||
|- | |- | ||
| 00:17 | | 00:17 | ||
− | | For this tutorial we are using | + | | For this tutorial, we are using: |
− | + | ||
− | '''Ubuntu 11.10''', | + | '''Ubuntu 11.10''', |
− | + | ||
'''JDK 1.6''' and | '''JDK 1.6''' and | ||
Line 35: | Line 32: | ||
|- | |- | ||
| 00:26 | | 00:26 | ||
− | | To follow this tutorial, you must have knowledge of '''data types '''in''' Java''' | + | | To follow this tutorial, you must have knowledge of '''data types''' in '''Java'''. |
− | + | ||
|- | |- | ||
| 00:31 | | 00:31 | ||
− | | If not, for relevant tutorials, please visit our website | + | | If not, for relevant tutorials, please visit our website as shown. |
|- | |- | ||
| 00:39 | | 00:39 | ||
− | | Relational operators are used to check for conditions. | + | | '''Relational operators''' are used to check for conditions. |
− | + | ||
|- | |- | ||
| 00:43 | | 00:43 | ||
− | + | | Their output is a variable of '''boolean''' data type. | |
− | | | + | |
− | + | ||
|- | |- | ||
| 00:48 | | 00:48 | ||
− | | A boolean data type is of size 1 bit | + | | A '''boolean''' data type is of size 1 '''bit'''. |
− | + | ||
|- | |- | ||
| 00:51 | | 00:51 | ||
| It stores only two values. | | It stores only two values. | ||
− | |||
|- | |- | ||
| 00:54 | | 00:54 | ||
− | | ''' | + | | '''true '''or '''false. ''' |
− | + | ||
|- | |- | ||
| 00:56 | | 00:56 | ||
− | | ''' | + | | '''true''' is the output when the condition is true. |
− | + | ||
|- | |- | ||
| 00:59 | | 00:59 | ||
− | | ''' | + | | '''false''' is the output if the condition is not true. |
|- | |- | ||
| 01:06 | | 01:06 | ||
− | | Here is a list of the | + | | Here is a list of the '''relational operators''' available. |
− | + | ||
|- | |- | ||
| 01:10 | | 01:10 | ||
− | | | + | | '''greater than''' |
+ | |||
|- | |- | ||
| 01:12 | | 01:12 | ||
− | | | + | | '''less than''' '''equal to''' |
+ | |||
|- | |- | ||
− | | 01 | + | | 01:14 |
− | + | | '''greater than''' or '''equal to''' '''less than''' or '''equal to''' | |
− | + | ||
− | + | ||
− | | | + | |
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
| 01:17 | | 01:17 | ||
− | | | + | | '''not equal to''' |
|- | |- | ||
| 01:19 | | 01:19 | ||
− | | | + | | We shall look into each of them in detail. |
|- | |- | ||
|01:22 | |01:22 | ||
− | | | + | | Switch to '''Eclipse.''' |
|- | |- | ||
|01:27 | |01:27 | ||
− | | | + | | Here we have the '''Eclipse IDE '''and the skeleton required for the rest of the code. |
− | + | ||
|- | |- | ||
| 01:33 | | 01:33 | ||
− | | | + | | I have created a class '''BooleanDemo''' and added the '''Main method'''. |
− | + | ||
|- | |- | ||
| 01:38 | | 01:38 | ||
− | | | + | | Now let us add some expressions. |
|- | |- | ||
| 01:41 | | 01:41 | ||
− | | Type '''boolean b ; ''' | + | | Type '''boolean b ;''' |
− | + | ||
|- | |- | ||
| 01:47 | | 01:47 | ||
| The keyword '''boolean''' declares the data type of the variable '''b''' as '''boolean.''' | | The keyword '''boolean''' declares the data type of the variable '''b''' as '''boolean.''' | ||
− | |||
|- | |- | ||
| 01:53 | | 01:53 | ||
− | | We shall store the result of our condition in b. | + | | We shall store the result of our condition in '''b'''. |
|- | |- | ||
| 01:58 | | 01:58 | ||
− | | We shall define a variable weight and check for a condition using that variable. | + | | We shall define a variable '''weight''' and check for a condition using that variable. |
− | + | ||
|- | |- | ||
| 02:05 | | 02:05 | ||
− | | '''int weight | + | | '''int weight ''' equal to '''45;''' |
− | + | ||
|- | |- | ||
| 02:13 | | 02:13 | ||
− | | We shall check if the value in weight is greater than '''40.''' | + | | We shall check if the value in '''weight''' is greater than '''40.''' |
− | + | ||
|- | |- | ||
| 02:18 | | 02:18 | ||
− | | '''b | + | | '''b ''' equal to '''weight ''' greater than '''40;''' |
− | + | ||
|- | |- | ||
| 02:28 | | 02:28 | ||
− | | This statement says check if the value of variable is greater than 40 and store the result in b | + | | This statement says: check if the value of variable is greater than 40 and store the result in 'b'. |
− | + | ||
|- | |- | ||
| 02:37 | | 02:37 | ||
− | | Now | + | | Now, let us print the value of 'b'. |
− | + | ||
|- | |- | ||
| 02:41 | | 02:41 | ||
− | | '''System | + | | '''System ''' dot '''out''' dot '''println(b);''' |
− | + | ||
|- | |- | ||
Line 182: | Line 156: | ||
|- | |- | ||
| 03:02 | | 03:02 | ||
− | | Let us see what | + | | Let us see what happens if the value is less than 40. |
− | + | ||
|- | |- | ||
| 03:07 | | 03:07 | ||
− | | Change weight to 30. | + | | Change '''weight''' to 30. |
− | + | ||
|- | |- | ||
| 03:12 | | 03:12 | ||
− | | Save and run | + | | '''Save''' and '''run'''. |
|- | |- | ||
− | | | + | | 03:20 |
− | | We can see that the output is False as expected. | + | | We can see that the output is '''False''' as expected. |
|- | |- | ||
| 03:24 | | 03:24 | ||
− | | This way, the | + | | This way, the ''greater than'' symbol is used to check if one value is ''greater than'' the other. |
− | + | ||
|- | |- | ||
| 03:30 | | 03:30 | ||
− | | | + | | Similarly, ''less than'' symbol is used to check if one value is ''less than'' the other. |
|- | |- | ||
− | | | + | | 03:37 |
− | | | + | | Let us change the ''greater than'' to ''less than'' symbol. |
− | + | ||
|- | |- | ||
| 03:43 | | 03:43 | ||
− | | | + | | So, We are checking if the value of '''weight''' is less than '''40'''. |
− | + | ||
|- | |- | ||
| 03:48 | | 03:48 | ||
− | | | + | | '''Save''', '''Run'''. |
|- | |- | ||
− | | | + | | 03:56 |
− | | | + | | As we can see, the output is '''true''' as expected. |
− | + | ||
|- | |- | ||
| 04:01 | | 04:01 | ||
− | | Let us change the value of weight to 45 and see the output. | + | | Let us change the value of '''weight''' to 45 and see the output. |
− | + | ||
|- | |- | ||
| 04:09 | | 04:09 | ||
− | | Save and Run. | + | | '''Save''' and '''Run'''. |
|- | |- | ||
| 04:16 | | 04:16 | ||
− | | We see that we get a | + | | We see that we get a '''false''' because the condition |
− | + | ||
|- | |- | ||
| 04:21 | | 04:21 | ||
− | | '''weight''''' less than '''''40''' is not true. | + | | '''weight''' ''less than'' '''40''' is not true. |
− | + | ||
|- | |- | ||
Line 251: | Line 216: | ||
|- | |- | ||
| 04:31 | | 04:31 | ||
− | | To do that, we use ''' | + | | To do that, we use two '''equal to symbols.''' |
− | + | ||
|- | |- | ||
| 04:35 | | 04:35 | ||
− | | | + | | Change ''less than'' symbol to ''double equal to.'' |
− | + | ||
|- | |- | ||
| 04:41 | | 04:41 | ||
− | | '''Save''' and '''Run''' | + | | '''Save''' and '''Run'''. |
|- | |- | ||
| 04:48 | | 04:48 | ||
− | | As we can see, the output is ''' | + | | As we can see, the output is '''false''' because the value of '''weight''' is not equal to '''40'''. |
|- | |- | ||
| 04:55 | | 04:55 | ||
− | | Now let us change the weight to 40 and see the output. | + | | Now let us change the '''weight''' to 40 and see the output. |
|- | |- | ||
| 05:01 | | 05:01 | ||
− | | Save and Run. | + | | '''Save''' and '''Run'''. |
|- | |- | ||
| 05:08 | | 05:08 | ||
− | | As we can see, the output is True | + | | As we can see, the output is '''True'''. |
− | + | ||
|- | |- | ||
| 05:12 | | 05:12 | ||
− | | This way, | + | | This way, ''double equal to'' is used for checking equality. |
− | + | ||
|- | |- | ||
| 05:16 | | 05:16 | ||
| Please be careful because, often people use a '''single equal to''' symbol for checking equality. | | Please be careful because, often people use a '''single equal to''' symbol for checking equality. | ||
− | |||
|- | |- | ||
| 05:22 | | 05:22 | ||
− | | And this gives unnecessary | + | | And this gives unnecessary '''error'''s. |
|- | |- | ||
| 05:26 | | 05:26 | ||
| Next we'll see how to check for '''less than or equal to.''' | | Next we'll see how to check for '''less than or equal to.''' | ||
− | |||
|- | |- | ||
| 05:30 | | 05:30 | ||
| To do that, we will use a '''less than''' symbol followed by an '''equal to''' symbol. | | To do that, we will use a '''less than''' symbol followed by an '''equal to''' symbol. | ||
− | |||
|- | |- | ||
| 05:35 | | 05:35 | ||
− | | | + | | Change the ''double equal to'', to ''less than equal to''. |
− | + | ||
|- | |- | ||
Line 315: | Line 272: | ||
|- | |- | ||
| 05:50 | | 05:50 | ||
− | | | + | | The output is '''True''' as expected. |
− | + | ||
|- | |- | ||
| 05:53 | | 05:53 | ||
− | | Now let us change the value of weight to see if the '''less than''' check is performed. | + | | Now let us change the value of '''weight''' to see if the '''less than''' check is performed. |
|- | |- | ||
Line 329: | Line 285: | ||
| 06:04 | | 06:04 | ||
| '''Save''' and '''Run.''' | | '''Save''' and '''Run.''' | ||
− | |||
|- | |- | ||
| 06:14 | | 06:14 | ||
− | | We see, that although the weight is not equal to 40 we get the output as '''True''' because it is less than 40. | + | | We see, that although the '''weight''' is not equal to 40 we get the output as '''True''' because it is less than 40. |
− | + | ||
|- | |- | ||
| 06:22 | | 06:22 | ||
− | | Let us see what happens if the value of weight is greater than 40. | + | | Let us see what happens if the value of '''weight''' is greater than 40. |
|- | |- | ||
− | | 06: | + | | 06:27 |
− | | Let say 50. Save and Run. | + | | Let's say 50. '''Save and Run'''. |
|- | |- | ||
| 06:39 | | 06:39 | ||
− | |As we can see, the output is False because the value of weight is not equal to 40. | + | |As we can see, the output is '''False''' because the value of '''weight''' is not equal to 40. |
− | + | ||
|- | |- | ||
Line 355: | Line 308: | ||
|- | |- | ||
| 06:48 | | 06:48 | ||
− | | Similarly we use a greater than symbol followed by an equal to symbol for checking '''greater than''' or''' equal to'''. | + | | Similarly, we use a ''greater than'' symbol followed by an ''equal to'' symbol for checking '''greater than''' or''' equal to'''. |
− | + | ||
|- | |- | ||
Line 364: | Line 316: | ||
|- | |- | ||
| 06:57 | | 06:57 | ||
− | | Change ''less than equal to'' to ''greater than equal to'' | + | | Change ''less than equal to'' to ''greater than equal to''. |
− | + | ||
|- | |- | ||
| 07:04 | | 07:04 | ||
− | | Save and Run. | + | | '''Save''' and '''Run.''' |
− | + | ||
|- | |- | ||
| 07:10 | | 07:10 | ||
− | | As we can see, the output is '''true '''because '''weight''' is greater than '''40''' | + | | As we can see, the output is '''true ''' because '''weight''' is greater than '''40'''. |
|- | |- | ||
− | | | + | | 07:16 |
− | | | + | | Let us change '''weight''' to a value less than 40. Let's say 30. |
− | + | ||
|- | |- | ||
| 07:25 | | 07:25 | ||
− | | Save and Run. | + | | '''Save''' and '''Run.''' |
|- | |- | ||
| 07:32 | | 07:32 | ||
− | | We get a false because the value of weight is not greater than 40 and also not equal to 40. | + | | We get a '''false''' because the value of '''weight''' is not greater than 40 and also not equal to 40. |
|- | |- | ||
| 07:39 | | 07:39 | ||
− | | Next, we’ll see how to check for '''not equal to''' | + | | Next, we’ll see how to check for '''not equal to'''. |
− | + | ||
|- | |- | ||
| 07:46 | | 07:46 | ||
| It is done by using an '''exclamation mark''' followed by an '''equal to''' symbol. | | It is done by using an '''exclamation mark''' followed by an '''equal to''' symbol. | ||
− | |||
|- | |- | ||
| 07:53 | | 07:53 | ||
− | | Change ''greater than'' to ''exclamation | + | | Change ''greater than'' to ''exclamation''. |
− | + | ||
|- | |- | ||
| 07:59 | | 07:59 | ||
− | | So this statement says check if the value of '''weight''' is not equal to '''40''' and store the result in '''b''' | + | | So, this statement says: check if the value of '''weight''' is not equal to '''40''' and store the result in '''b'''. |
− | + | ||
|- | |- | ||
| 08:08 | | 08:08 | ||
− | | '''Save''' and '''Run''' | + | | '''Save''' and '''Run'''. |
|- | |- | ||
− | | | + | | 08:16 |
− | | | + | | As we can see, the output is '''true''' because the values of weight is not equal to 40. |
|- | |- | ||
− | | | + | | 08:23 |
− | | | + | | Let us change the '''weight''' to 40 and see the output. |
|- | |- | ||
| 08:28 | | 08:28 | ||
− | | | + | | Change 30 to 40. |
|- | |- | ||
| 08:31 | | 08:31 | ||
− | | | + | | '''Save, Run'''. |
|- | |- | ||
| 08:38 | | 08:38 | ||
− | | | + | | We get a '''false''' because the condition '''weight''' not equal to 40 is false. |
|- | |- | ||
| 08:45 | | 08:45 | ||
− | | The not equal to condition can be thought of as opposite of equal to condition. | + | | The '''not equal''' to condition can be thought of as opposite of '''equal to''' condition. |
|- | |- | ||
| 08:50 | | 08:50 | ||
− | | This is how we use the various relational operators to compare data in Java. | + | | This is how we use the various '''relational operators''' to compare data in Java. |
|- | |- | ||
− | | | + | | 08:58 |
− | | | + | | This brings us to the end of this tutorial. |
− | + | ||
|- | |- | ||
| 09:01 | | 09:01 | ||
− | | | + | | In this tutorial we have learnt about: the boolean data type, |
|- | |- | ||
| 09:06 | | 09:06 | ||
− | | | + | | the '''relational operators''' and |
|- | |- | ||
| 09:08 | | 09:08 | ||
− | | how to use '''relational operators''' to | + | | how to use '''relational operators''' to compare data. |
|- | |- | ||
− | | | + | | 09:13 |
− | | | + | | As an assignment for this tutorial, find out if the two expressions shown are equivalent. |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
| 09:23 | | 09:23 | ||
− | | | + | |To know more about the Spoken Tutorial project,watch the video available at [http://spoken-tutorial.org/What_is_a_Spoken_Tutorial]. |
|- | |- | ||
| 09:28 | | 09:28 | ||
− | | | + | | It summarizes the Spoken Tutorial project. |
|- | |- | ||
| 09:31 | | 09:31 | ||
− | | | + | | If you do not have good bandwidth, you can download and watch it. |
− | + | ||
− | + | ||
|- | |- | ||
− | | | + | | 09:36 |
− | | | + | | The Spoken Tutorial Project Team: |
− | + | ||
|- | |- | ||
| 09:38 | | 09:38 | ||
− | | | + | | Conducts workshops using 'Spoken Tutorials'. |
− | + | ||
|- | |- | ||
| 09:40 | | 09:40 | ||
− | | | + | | Gives certificates for those who pass an online test. For more details, please write to '''contact AT spoken HYPHEN tutorial DOT org.''' |
|- | |- | ||
− | | | + | | 09:50 |
− | | | + | | Spoken Tutorial Project is a part of the 'Talk to a Teacher' project. |
− | + | ||
|- | |- | ||
| 09:54 | | 09:54 | ||
− | | It is supported by the | + | | It is supported by the National Mission on Education through ICT, MHRD, Government of India. |
− | + | ||
|- | |- | ||
| 10:00 | | 10:00 | ||
− | | | + | | More information on this mission is available at '''spoken HYPHEN tutorial DOT org SLASH NMEICT HYPHEN Intro'''. |
|- | |- | ||
| 10:05 | | 10:05 | ||
− | | | + | | This tutorial has been contributed by '''TalentSprint'''. Thanks for joining. |
− | + | ||
− | + | ||
− | + | ||
|} | |} |
Latest revision as of 15:55, 7 April 2017
Time | Narration |
00:01 | Welcome to the spoken tutorial on Relational Operators in Java. |
00:07 | In this tutorial, we will learn about the |
00:09 | boolean data type,Relational operators and |
00:12 | how to compare data using Relational operators. |
00:17 | For this tutorial, we are using:
Ubuntu 11.10, JDK 1.6 and Eclipse 3.7 |
00:26 | To follow this tutorial, you must have knowledge of data types in Java. |
00:31 | If not, for relevant tutorials, please visit our website as shown. |
00:39 | Relational operators are used to check for conditions. |
00:43 | Their output is a variable of boolean data type. |
00:48 | A boolean data type is of size 1 bit. |
00:51 | It stores only two values. |
00:54 | true or false. |
00:56 | true is the output when the condition is true. |
00:59 | false is the output if the condition is not true. |
01:06 | Here is a list of the relational operators available. |
01:10 | greater than |
01:12 | less than equal to |
01:14 | greater than or equal to less than or equal to |
01:17 | not equal to |
01:19 | We shall look into each of them in detail. |
01:22 | Switch to Eclipse. |
01:27 | Here we have the Eclipse IDE and the skeleton required for the rest of the code. |
01:33 | I have created a class BooleanDemo and added the Main method. |
01:38 | Now let us add some expressions. |
01:41 | Type boolean b ; |
01:47 | The keyword boolean declares the data type of the variable b as boolean. |
01:53 | We shall store the result of our condition in b. |
01:58 | We shall define a variable weight and check for a condition using that variable. |
02:05 | int weight equal to 45; |
02:13 | We shall check if the value in weight is greater than 40. |
02:18 | b equal to weight greater than 40; |
02:28 | This statement says: check if the value of variable is greater than 40 and store the result in 'b'. |
02:37 | Now, let us print the value of 'b'. |
02:41 | System dot out dot println(b); |
02:49 | Save and Run. |
02:59 | As we can see, the output is True. |
03:02 | Let us see what happens if the value is less than 40. |
03:07 | Change weight to 30. |
03:12 | Save and run. |
03:20 | We can see that the output is False as expected. |
03:24 | This way, the greater than symbol is used to check if one value is greater than the other. |
03:30 | Similarly, less than symbol is used to check if one value is less than the other. |
03:37 | Let us change the greater than to less than symbol. |
03:43 | So, We are checking if the value of weight is less than 40. |
03:48 | Save, Run. |
03:56 | As we can see, the output is true as expected. |
04:01 | Let us change the value of weight to 45 and see the output. |
04:09 | Save and Run. |
04:16 | We see that we get a false because the condition |
04:21 | weight less than 40 is not true. |
04:25 | Now let us see how to check if a value is equal to another. |
04:31 | To do that, we use two equal to symbols. |
04:35 | Change less than symbol to double equal to. |
04:41 | Save and Run. |
04:48 | As we can see, the output is false because the value of weight is not equal to 40. |
04:55 | Now let us change the weight to 40 and see the output. |
05:01 | Save and Run. |
05:08 | As we can see, the output is True. |
05:12 | This way, double equal to is used for checking equality. |
05:16 | Please be careful because, often people use a single equal to symbol for checking equality. |
05:22 | And this gives unnecessary errors. |
05:26 | Next we'll see how to check for less than or equal to. |
05:30 | To do that, we will use a less than symbol followed by an equal to symbol. |
05:35 | Change the double equal to, to less than equal to. |
05:42 | Save and Run. |
05:50 | The output is True as expected. |
05:53 | Now let us change the value of weight to see if the less than check is performed. |
05:59 | Change 40 to 30. |
06:04 | Save and Run. |
06:14 | We see, that although the weight is not equal to 40 we get the output as True because it is less than 40. |
06:22 | Let us see what happens if the value of weight is greater than 40. |
06:27 | Let's say 50. Save and Run. |
06:39 | As we can see, the output is False because the value of weight is not equal to 40. |
06:44 | And it also not less than 40. |
06:48 | Similarly, we use a greater than symbol followed by an equal to symbol for checking greater than or equal to. |
06:55 | Let us try it. |
06:57 | Change less than equal to to greater than equal to. |
07:04 | Save and Run. |
07:10 | As we can see, the output is true because weight is greater than 40. |
07:16 | Let us change weight to a value less than 40. Let's say 30. |
07:25 | Save and Run. |
07:32 | We get a false because the value of weight is not greater than 40 and also not equal to 40. |
07:39 | Next, we’ll see how to check for not equal to. |
07:46 | It is done by using an exclamation mark followed by an equal to symbol. |
07:53 | Change greater than to exclamation. |
07:59 | So, this statement says: check if the value of weight is not equal to 40 and store the result in b. |
08:08 | Save and Run. |
08:16 | As we can see, the output is true because the values of weight is not equal to 40. |
08:23 | Let us change the weight to 40 and see the output. |
08:28 | Change 30 to 40. |
08:31 | Save, Run. |
08:38 | We get a false because the condition weight not equal to 40 is false. |
08:45 | The not equal to condition can be thought of as opposite of equal to condition. |
08:50 | This is how we use the various relational operators to compare data in Java. |
08:58 | This brings us to the end of this tutorial. |
09:01 | In this tutorial we have learnt about: the boolean data type, |
09:06 | the relational operators and |
09:08 | how to use relational operators to compare data. |
09:13 | As an assignment for this tutorial, find out if the two expressions shown are equivalent. |
09:23 | To know more about the Spoken Tutorial project,watch the video available at [1]. |
09:28 | It summarizes the Spoken Tutorial project. |
09:31 | If you do not have good bandwidth, you can download and watch it. |
09:36 | The Spoken Tutorial Project Team: |
09:38 | Conducts workshops using 'Spoken Tutorials'. |
09:40 | Gives certificates for those who pass an online test. For more details, please write to contact AT spoken HYPHEN tutorial DOT org. |
09:50 | Spoken Tutorial Project is a part of the 'Talk to a Teacher' project. |
09:54 | It is supported by the National Mission on Education through ICT, MHRD, Government of India. |
10:00 | More information on this mission is available at spoken HYPHEN tutorial DOT org SLASH NMEICT HYPHEN Intro. |
10:05 | This tutorial has been contributed by TalentSprint. Thanks for joining. |