Difference between revisions of "Java/C2/Creating-class/English-timed"
From Script | Spoken-Tutorial
Sandhya.np14 (Talk | contribs) |
|||
Line 4: | Line 4: | ||
|- | |- | ||
| 00:02 | | 00:02 | ||
− | | Welcome to the spoken tutorial on '''Creating | + | | Welcome to the spoken tutorial on '''Creating classes'''. |
|- | |- | ||
| 00:05 | | 00:05 | ||
− | | In this tutorial, we will learn about | + | | In this tutorial, we will learn about: |
|- | |- | ||
| 00:08 | | 00:08 | ||
− | | A '''class '''in real world | + | |* A '''class''' in real world |
|- | |- | ||
| 00:10 | | 00:10 | ||
− | | A '''class '''in Java | + | |* A '''class''' in Java |
|- | |- | ||
| 00:12 | | 00:12 | ||
− | | Structure of a''' Java class''' | + | |* Structure of a '''Java class''' |
|- | |- | ||
| 00:14 | | 00:14 | ||
− | | Syntax for a''' Java class''' | + | |* Syntax for a''' Java class''' |
|- | |- | ||
| 00:16 | | 00:16 | ||
− | | And | + | |* And a simple example of '''Java class'''. |
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
| 00:19 | | 00:19 | ||
− | | Here we are using | + | | Here we are using: |
− | + | ||
* Ubuntu version 11.10 | * Ubuntu version 11.10 | ||
* JDK 1.6 and | * JDK 1.6 and | ||
* Eclipse 3.7.0 | * Eclipse 3.7.0 | ||
− | |||
− | |||
− | |||
|- | |- | ||
| 00:30 | | 00:30 | ||
− | | To follow this tutorial you must know how to write, compile and run a simple Java program in Eclipse. | + | | To follow this tutorial, you must know how to write, compile and '''run''' a simple Java program in '''Eclipse'''. |
− | + | ||
|- | |- | ||
| 00:37 | | 00:37 | ||
− | |If not, please see the spoken-tutorial on these topics available at '''spoken-tutorial.org'''. | + | |If not, please see the spoken-tutorial on these topics, available at '''spoken-tutorial.org'''. |
|- | |- | ||
| 00:46 | | 00:46 | ||
| Now let us see what is a '''class '''in real world. | | Now let us see what is a '''class '''in real world. | ||
− | |||
|- | |- | ||
| 00:50 | | 00:50 | ||
|Whatever we can see in this world are all objects. | |Whatever we can see in this world are all objects. | ||
− | |||
|- | |- | ||
| 00:54 | | 00:54 | ||
− | |And | + | |And all the objects can be categorized into special groups. |
− | + | ||
|- | |- | ||
| 00:59 | | 00:59 | ||
− | |Each group is termed as a class. | + | |Each group is termed as a '''class'''. |
− | + | ||
|- | |- | ||
| 01:02 | | 01:02 | ||
− | |For example human being is a class. | + | |For example, human being is a '''class'''. |
− | + | ||
|- | |- | ||
| 01:05 | | 01:05 | ||
− | |We are all different objects of this class. | + | |We are all different objects of this '''class'''. |
− | + | ||
|- | |- | ||
| 01:08 | | 01:08 | ||
|We all have different properties like eyes, legs, hands etc. | |We all have different properties like eyes, legs, hands etc. | ||
− | |||
|- | |- | ||
| 01:13 | | 01:13 | ||
| Which are common to the human being class. | | Which are common to the human being class. | ||
− | |||
|- | |- | ||
Line 94: | Line 78: | ||
|- | |- | ||
| 01:22 | | 01:22 | ||
− | |Now let us see what is the class in '''Java'''? | + | |Now let us see what is the '''class''' in '''Java'''? |
− | + | ||
|- | |- | ||
| 01:26 | | 01:26 | ||
− | | | + | | A''' class '''is the blueprint from which individual objects are created. |
|- | |- | ||
| 01:31 | | 01:31 | ||
− | |Structure of a | + | | Structure of a '''Java Class'''; A '''class''' defines: |
− | + | ||
|- | |- | ||
| 01:35 | | 01:35 | ||
− | |A set of properties called''' variables ''' | + | |* A set of properties called '''variables '''. |
− | + | ||
|- | |- | ||
| 01:37 | | 01:37 | ||
− | |And A set of behaviors called''' methods.''' | + | |* And A set of behaviors called '''methods.''' |
|- | |- | ||
| 01:40 | | 01:40 | ||
− | | Now, let us see the syntax for declaring | + | | Now, let us see the syntax for declaring '''class'''es. |
− | + | ||
|- | |- | ||
| 01:44 | | 01:44 | ||
− | |'''modifier – class -classname''' within curly brackets '''variable, constructor''' and''' method '''declarations. | + | |'''modifier – class -classname''' within curly brackets '''variable, constructor''' and '''method''' declarations. |
− | + | ||
|- | |- | ||
| 01:52 | | 01:52 | ||
− | |We will learn about these in detail in the coming tutorials. | + | |We will learn about these in detail, in the coming tutorials. |
|- | |- | ||
| 01:58 | | 01:58 | ||
− | |Now | + | |Now, let us create a simple '''class ''' using '''Eclipse'''. |
− | + | ||
|- | |- | ||
| 02:03 | | 02:03 | ||
− | |I have already opened''' Eclipse'''. | + | |I have already opened '''Eclipse'''. |
− | + | ||
|- | |- | ||
| 02:09 | | 02:09 | ||
|Now let us create a '''Project.''' | |Now let us create a '''Project.''' | ||
− | |||
|- | |- | ||
| 02:11 | | 02:11 | ||
− | |So click on '''File,''' go to '''New '''and click on''' Java Project.''' | + | |So click on '''File,''' go to '''New ''' and click on '''Java Project.''' |
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
| 02:20 | | 02:20 | ||
− | | | + | | In the '''New Project''' Wizard, enter the '''Project name ''' as '''ClassDemo''' with C and D in capital. |
− | + | ||
|- | |- | ||
| 02:34 | | 02:34 | ||
|Then click on '''Finish'''. | |Then click on '''Finish'''. | ||
− | |||
− | |||
− | |||
|- | |- | ||
Line 169: | Line 138: | ||
|- | |- | ||
|02:43 | |02:43 | ||
− | | We will now create a''' Java class ''' name '''Student'''. | + | | We will now create a '''Java class''' name '''Student'''. |
− | + | ||
|- | |- | ||
| 02:47 | | 02:47 | ||
− | |So right click on''' ClassDemo''', go to''' New''' and click on '''Class'''. | + | |So, right click on''' ClassDemo''', go to''' New''' and click on '''Class'''. |
− | + | ||
|- | |- | ||
| 02:56 | | 02:56 | ||
− | |In the '''New Java Class | + | |In the '''New Java Class''' wizard, type the '''Name''' as '''Student.''' |
− | + | ||
|- | |- | ||
| 03:03 | | 03:03 | ||
|We can see that the '''modifier''' here is''' public'''. | |We can see that the '''modifier''' here is''' public'''. | ||
− | |||
|- | |- | ||
| 03:07 | | 03:07 | ||
− | |This shows that the class is visible to all the classes everywhere. | + | |This shows that the '''class''' is visible to all the classes everywhere. |
− | + | ||
|- | |- | ||
| 03:11 | | 03:11 | ||
− | |If a class has no '''modifier''' which is the '''default''' , it is visible only within its own '''package.''' | + | |If a '''class''' has no '''modifier''' which is the '''default''', it is visible only within its own '''package.''' |
|- | |- | ||
| 03:18 | | 03:18 | ||
|We will learn about '''packages''' in the later tutorials. | |We will learn about '''packages''' in the later tutorials. | ||
− | |||
|- | |- | ||
| 03:23 | | 03:23 | ||
− | | Here I have selected''' public.''' | + | | Here I have selected '''public.''' |
− | + | ||
|- | |- | ||
| 03:26 | | 03:26 | ||
− | |In the method stubs select '''public static void main.''' | + | |In the 'method stubs', select '''public static void main.''' |
− | + | ||
|- | |- | ||
| 03:31 | | 03:31 | ||
|Then click on '''Finish'''. | |Then click on '''Finish'''. | ||
− | |||
|- | |- | ||
| 03:36 | | 03:36 | ||
− | |We can see that the class named '''Student '''is created. | + | |We can see that the '''class''' named '''Student''' is created. |
− | + | ||
|- | |- | ||
| 03:40 | | 03:40 | ||
|Now, let me remove the comments. | |Now, let me remove the comments. | ||
− | |||
− | |||
− | |||
|- | |- | ||
| 03:51 | | 03:51 | ||
| A '''Student class''' can contain properties like Name, Roll Number, Marks etc. | | A '''Student class''' can contain properties like Name, Roll Number, Marks etc. | ||
− | |||
|- | |- | ||
| 03:57 | | 03:57 | ||
− | |So inside this''' class Student''' let me declare two '''variables''' '''Roll Number''' and '''Name'''. | + | |So, inside this '''class Student''', let me declare two '''variables''' '''Roll Number''' and '''Name'''. |
− | + | ||
|- | |- | ||
| 04:04 | | 04:04 | ||
− | |So, I will type''' int roll | + | |So, I will type '''int roll''' underscore '''number''' semicolon'. |
− | + | ||
|- | |- | ||
| 04:14 | | 04:14 | ||
− | | '''String name | + | | '''String name''' semicolon. |
− | + | ||
|- | |- | ||
| 04:19 | | 04:19 | ||
− | |So I have declared two '''variables.''' | + | |So, I have declared two '''variables.''' |
− | + | ||
|- | |- | ||
| 04:22 | | 04:22 | ||
− | |Now a class also contains''' methods.''' | + | |Now, a '''class''' also contains '''methods.''' |
− | + | ||
|- | |- | ||
| 04:25 | | 04:25 | ||
− | |So let me create a method named '''StudentDetail.''' | + | |So, let me create a '''method''' named '''StudentDetail.''' |
− | + | ||
|- | |- | ||
| 04:30 | | 04:30 | ||
− | |This method will give the detail of each student. | + | |This '''method''' will give the detail of each student. |
− | + | ||
|- | |- | ||
| 04:34 | | 04:34 | ||
− | |So let me type, | + | |So let me type, '''void studentDetail''' then opening and closing brackets, curly brackets open. |
− | + | ||
|- | |- | ||
| 04:49 | | 04:49 | ||
− | |Now, this method will give the roll number and name of the Student. | + | |Now, this '''method''' will give the roll number and name of the Student. |
− | + | ||
|- | |- | ||
| 04:53 | | 04:53 | ||
− | |So, type '''System | + | |So, type '''System''' dot '''out''' dot '''println''' within brackets and double quotes '''The roll number is ''' we can type it as number is, close the double quotes plus '''roll_number''' semicolon . |
− | + | ||
|- | |- | ||
| 05:23 | | 05:23 | ||
− | |Next line type '''System | + | |Next line, type: '''System''' dot '''out''' dot '''println''' within brackets and double quotes '''The name is''' plus '''name''' and semicolon. |
− | + | ||
|- | |- | ||
| 05:40 | | 05:40 | ||
− | |Now, inside the main method we will type '''System | + | |Now, inside the '''main method''' we will type: '''System''' dot '''out''' dot '''println''' within brackets and double quotes '''We have created a class with two variables and 1 method.''' |
|- | |- | ||
| 06:10 | | 06:10 | ||
− | |Thus | + | |Thus, We have created the '''class''' '''student'''. |
|- | |- | ||
| 06:20 | | 06:20 | ||
− | |Now let me | + | |Now, let me '''save''' the file by pressing '''Control''' and '''S''' keys simultaneously. |
− | + | ||
|- | |- | ||
| 06:26 | | 06:26 | ||
− | |Let me'''Run '''the program by pressing '''Control '''and '''F11''' keys simultaneously. | + | |Let me '''Run''' the program by pressing '''Control''' and '''F11''' keys simultaneously. |
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
| 06:33 | | 06:33 | ||
| We get the output as : | | We get the output as : | ||
− | |||
|- | |- | ||
| 06:34 | | 06:34 | ||
− | |'''We have created a class with 2 variables and 1 method ''' | + | |'''We have created a class with 2 variables and 1 method ''', |
− | + | ||
|- | |- | ||
| 06:38 | | 06:38 | ||
− | |just as we had typed in the main method. | + | |just as we had typed in the '''main method'''. |
− | + | ||
|- | |- | ||
Line 329: | Line 266: | ||
|- | |- | ||
| 06:50 | | 06:50 | ||
− | | | + | | So, in this tutorial, we learnt about a '''class''' in java and how to create a '''class''' in java. |
|- | |- | ||
| 06:59 | | 06:59 | ||
− | | For self assessment create a '''class''' named '''Employee '''with ''' | + | | For self assessment, create a '''class''' named '''Employee''' with variables '''emp''' underscore '''number''' and '''emp''' underscore '''name''' . |
|- | |- | ||
| 07:10 | | 07:10 | ||
− | |And | + | |And '''method''' '''printEmployee''' which displays the '''Employee''' information. |
|- | |- | ||
| 07:16 | | 07:16 | ||
− | | To know more about the spoken-tutorial project | + | | To know more about the spoken-tutorial project, |
− | + | ||
|- | |- | ||
| 07:19 | | 07:19 | ||
− | | | + | | watch the video available at [http://spoken-tutorial.org/What_is_a_Spoken_Tutorial] |
|- | |- | ||
| 07:22 | | 07:22 | ||
− | | It | + | | It summarizes the Spoken Tutorial project. |
|- | |- | ||
| 07:25 | | 07:25 | ||
− | | If you do not have good bandwidth, you can download and watch it | + | | If you do not have good bandwidth, you can download and watch it. |
− | + | ||
− | + | ||
|- | |- | ||
| 07:30 | | 07:30 | ||
− | | | + | | The Spoken Tutorial project team: |
|- | |- | ||
| 07:32 | | 07:32 | ||
− | | Conducts workshops using spoken tutorials | + | | Conducts workshops using spoken tutorials. |
|- | |- | ||
| 07:35 | | 07:35 | ||
− | |Gives certificates to those who pass an online test | + | |Gives certificates to those who pass an online test. |
|- | |- | ||
| 07:38 | | 07:38 | ||
− | | | + | | For more details, please write to contact@spoken-tutorial.org |
− | + | ||
− | + | ||
|- | |- | ||
| 07:44 | | 07:44 | ||
− | | Spoken Tutorial | + | | Spoken Tutorial project is a part of the Talk to a Teacher project. |
|- | |- | ||
Line 385: | Line 317: | ||
|- | |- | ||
| 07:55 | | 07:55 | ||
− | | More information on this | + | | More information on this mission is available at |
− | + | [http://spoken-tutorial.org/NMEICT-Intro]. | |
− | + | ||
− | + | ||
|- | |- | ||
| 08:04 | | 08:04 | ||
− | | Thus | + | | Thus, we come to the end of this tutorial. |
− | + | ||
|- | |- | ||
| 08:07 | | 08:07 | ||
− | |This is Arya Ratish from IIT Bomaby signing off. Thanks for joining us. | + | |This is Arya Ratish from IIT Bomaby, signing off. Thanks for joining us. |
Revision as of 12:42, 30 March 2015
Time | Narration |
00:02 | Welcome to the spoken tutorial on Creating classes. |
00:05 | In this tutorial, we will learn about: |
00:08 | * A class in real world |
00:10 | * A class in Java |
00:12 | * Structure of a Java class |
00:14 | * Syntax for a Java class |
00:16 | * And a simple example of Java class. |
00:19 | Here we are using:
|
00:30 | To follow this tutorial, you must know how to write, compile and run a simple Java program in Eclipse. |
00:37 | If not, please see the spoken-tutorial on these topics, available at spoken-tutorial.org. |
00:46 | Now let us see what is a class in real world. |
00:50 | Whatever we can see in this world are all objects. |
00:54 | And all the objects can be categorized into special groups. |
00:59 | Each group is termed as a class. |
01:02 | For example, human being is a class. |
01:05 | We are all different objects of this class. |
01:08 | We all have different properties like eyes, legs, hands etc. |
01:13 | Which are common to the human being class. |
01:15 | Seeing, eating, walking etc are behaviors that are common to the human being class. |
01:22 | Now let us see what is the class in Java? |
01:26 | A class is the blueprint from which individual objects are created. |
01:31 | Structure of a Java Class; A class defines: |
01:35 | * A set of properties called variables . |
01:37 | * And A set of behaviors called methods. |
01:40 | Now, let us see the syntax for declaring classes. |
01:44 | modifier – class -classname within curly brackets variable, constructor and method declarations. |
01:52 | We will learn about these in detail, in the coming tutorials. |
01:58 | Now, let us create a simple class using Eclipse. |
02:03 | I have already opened Eclipse. |
02:09 | Now let us create a Project. |
02:11 | So click on File, go to New and click on Java Project. |
02:20 | In the New Project Wizard, enter the Project name as ClassDemo with C and D in capital. |
02:34 | Then click on Finish. |
02:38 | We see that the Project ClassDemo is created. |
02:43 | We will now create a Java class name Student. |
02:47 | So, right click on ClassDemo, go to New and click on Class. |
02:56 | In the New Java Class wizard, type the Name as Student. |
03:03 | We can see that the modifier here is public. |
03:07 | This shows that the class is visible to all the classes everywhere. |
03:11 | If a class has no modifier which is the default, it is visible only within its own package. |
03:18 | We will learn about packages in the later tutorials. |
03:23 | Here I have selected public. |
03:26 | In the 'method stubs', select public static void main. |
03:31 | Then click on Finish. |
03:36 | We can see that the class named Student is created. |
03:40 | Now, let me remove the comments. |
03:51 | A Student class can contain properties like Name, Roll Number, Marks etc. |
03:57 | So, inside this class Student, let me declare two variables Roll Number and Name. |
04:04 | So, I will type int roll underscore number semicolon'. |
04:14 | String name semicolon. |
04:19 | So, I have declared two variables. |
04:22 | Now, a class also contains methods. |
04:25 | So, let me create a method named StudentDetail. |
04:30 | This method will give the detail of each student. |
04:34 | So let me type, void studentDetail then opening and closing brackets, curly brackets open. |
04:49 | Now, this method will give the roll number and name of the Student. |
04:53 | So, type System dot out dot println within brackets and double quotes The roll number is we can type it as number is, close the double quotes plus roll_number semicolon . |
05:23 | Next line, type: System dot out dot println within brackets and double quotes The name is plus name and semicolon. |
05:40 | Now, inside the main method we will type: System dot out dot println within brackets and double quotes We have created a class with two variables and 1 method. |
06:10 | Thus, We have created the class student. |
06:20 | Now, let me save the file by pressing Control and S keys simultaneously. |
06:26 | Let me Run the program by pressing Control and F11 keys simultaneously. |
06:33 | We get the output as : |
06:34 | We have created a class with 2 variables and 1 method , |
06:38 | just as we had typed in the main method. |
06:46 | Thus we have successfully created a class. |
06:50 | So, in this tutorial, we learnt about a class in java and how to create a class in java. |
06:59 | For self assessment, create a class named Employee with variables emp underscore number and emp underscore name . |
07:10 | And method printEmployee which displays the Employee information. |
07:16 | To know more about the spoken-tutorial project, |
07:19 | watch the video available at [1] |
07:22 | It summarizes the Spoken Tutorial project. |
07:25 | If you do not have good bandwidth, you can download and watch it. |
07:30 | The Spoken Tutorial project team: |
07:32 | Conducts workshops using spoken tutorials. |
07:35 | Gives certificates to those who pass an online test. |
07:38 | For more details, please write to contact@spoken-tutorial.org |
07:44 | Spoken Tutorial project is a part of the Talk to a Teacher project. |
07:48 | It is supported by the National Mission on Education through ICT, MHRD, Government of India |
07:55 | More information on this mission is available at
[2]. |
08:04 | Thus, we come to the end of this tutorial. |
08:07 | This is Arya Ratish from IIT Bomaby, signing off. Thanks for joining us. |