Difference between revisions of "Java/C2/Default-constructor/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with '{| border=1 || ''Time''' || '''Narration''' |- | 00:02 | Welcome to the Spoken Tutorial on '''default''' '''constructor''' in''' java'''. |- | 00:07 | In this tutorial …')
 
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
{| border=1
 
{| border=1
|| ''Time'''
+
|| '''Time'''
 
|| '''Narration'''  
 
|| '''Narration'''  
 
   
 
   
 
|-
 
|-
 
|  00:02
 
|  00:02
|  Welcome to the Spoken Tutorial on '''default''' '''constructor''' in''' java'''.
+
|  Welcome to the Spoken Tutorial on '''Default constructor''' in''' java'''.
  
 
|-
 
|-
 
|  00:07  
 
|  00:07  
|  In this tutorial we will learn  
+
|  In this tutorial, we will learn:
  
 
|-
 
|-
 
|  00:10
 
|  00:10
| About the default constructor.   
+
| About the default constructor.   
  
 
|-
 
|-
 
|  00:12
 
|  00:12
| And  to create a constructor.  
+
|And  to create a constructor.  
  
 
|-
 
|-
 
|  00:15
 
|  00:15
|   Here we are using  
+
| Here we are using:
 
+
'''Ubuntu version 11.10'''
* Ubuntu version 11.10  
+
'''Java Development Environment jdk 1.6''' and  
* Java Development Environment jdk 1.6 and  
+
'''Eclipse 3.7.0'''
Eclipse 3.7.0
+
 
+
 
+
  
 
|-
 
|-
 
|  00:26
 
|  00:26
|  To follow this tutorial you must know  
+
|  To follow this tutorial, you must know  
  
 
|-
 
|-
 
|  00:29
 
|  00:29
| how to create a class and the object of the class in '''java''' using '''eclipse'''.
+
| how to create a '''class''' and the '''object''' of the class in java using '''eclipse'''.
 
+
  
 
|-
 
|-
 
|  00:34
 
|  00:34
| If not, for relevant tutorials please visit our website which is as shown,
+
| If not, for relevant tutorials, please visit our website which is as shown.http://www.spoken-tutorial.org  
 
+
(http://www.spoken-tutorial.org)
+
 
+
  
 
|-
 
|-
 
|  00:42
 
|  00:42
|  '''Constructor''' is used to initialize the instance variables.
+
|  '''Constructor''' is used to initialize the '''instance''' variables.
 
+
  
 
|-
 
|-
 
|  00:46  
 
|  00:46  
 
| It is called at the creation of new object.
 
| It is called at the creation of new object.
 
 
 
  
 
|-
 
|-
 
|  00:50
 
|  00:50
|  Let us now see how '''constructor''' is defined in java.
+
|  Let us now see how a '''constructor''' is defined in java.
 
+
  
 
|-
 
|-
 
|  00:55
 
|  00:55
| So in the '''eclipse,''' I have already created a java file, '''Student.java'''
+
| So, in the '''eclipse''', I have already created a java file '''Student.java'''.
  
 
|-
 
|-
 
| 01:02
 
| 01:02
|  In the Student class we will declare two variables.
+
|  In the '''Student''' '''class''' we will declare two variables.
 
+
  
 
|-
 
|-
 
|  01:07
 
|  01:07
| So type '''''int''''' '''''roll_number''''' ''semi-colon'' and '''''String''''' '''''name''''' semi''-colon.''
+
| So type '''int''' '''roll_number''' semi-colon and '''String''' '''name''' semicolon.  
  
 
|-
 
|-
Line 81: Line 68:
 
|-
 
|-
 
|  01:22
 
|  01:22
| So type '''''void''''' '''''studentDetail()'''''
+
| So, type: '''void''' '''studentDetail()'''.
  
 
|-
 
|-
 
|  01:33
 
|  01:33
| Within curly ''brackets'' type '''''System''''' ''dot'' '''''out''''' ''dot'' '''''println''''' '''''roll_number'''''
+
| Within curly brackets, type: '''System''' dot '''out''' dot '''println''' '''roll_number;'''
  
 
|-
 
|-
 
|  01:50   
 
|  01:50   
| Then '''''System''''' ''dot'' '''''out''''' ''dot'' '''''println''''' '''''name'''''
+
| Then '''System''' dot '''out''' dot '''println''' '''name;'''.
  
 
|-
 
|-
 
|02:03   
 
|02:03   
|  Now in '''Main''' method we will call this method.
+
|  Now in '''main''' '''method''' we will call this method.
  
 
|-
 
|-
 
|  02:08
 
|  02:08
| So let us create an object and call the method.
+
| So, let us create an object and call the '''method'''.
 
+
  
 
|-
 
|-
 
|  02:14
 
|  02:14
| So type '''''Student''''' object name '''''stu''''' ''equal'' ''to'' '''''new''''' '''''Student'''''
+
| So, type: '''Student''' object name '''stu''' equal to '''new''' '''Student()'''.
  
 
|-
 
|-
 
|  02:28
 
|  02:28
| Then '''''stu''''' ''dot'' method name i.e'''''studentDetail'''''
+
| Then '''stu''' dot method name i.e '''studentDetail'''.
  
 
|-
 
|-
 
|  02:41
 
|  02:41
|Save and '''Run '''the program.
+
|'''Save''' and '''Run '''the program.
  
 
|-
 
|-
 
|  02:46
 
|  02:46
|   We see the output zero and null.
+
| We see the output 'zero' and 'null'.
  
 
|-
 
|-
 
|  02:49
 
|  02:49
| So, the int variable '''roll_number''' has been initialized to its default value zero.
+
| So, the '''int''' variable '''roll_number''' has been initialized to its default value 'zero'.
  
 
|-
 
|-
 
|  02:56
 
|  02:56
| And the String '''name''' has been initialized to its default value null.
+
| And the '''String''' '''name''' has been initialized to its default value 'null'.
 
+
  
 
|-
 
|-
 
|  03:02
 
|  03:02
| If we do not define a constructor then a default constructor is created.
+
| If we do not define a '''constructor''' then a default constructor is created.
 
+
  
 
|-
 
|-
 
|  03:08
 
|  03:08
| Default constructor has no parameters.
+
| Default '''constructor''' has no parameters.
  
 
|-
 
|-
 
|  03:11
 
|  03:11
 
| It initializes the instance variables to their default value.
 
| It initializes the instance variables to their default value.
 
  
 
|-
 
|-
Line 145: Line 128:
 
|-
 
|-
 
|  03:18
 
|  03:18
| So type '''''Student''''' ''parenthesis'' and curly brackets.
+
| So, type: '''Student''' S capital parenthesis and curly brackets.
 
+
  
 
|-
 
|-
 
|  03:30
 
|  03:30
| Remember the '''Constructor''' has the same name as the class name to which it belongs.
+
| Remember, the '''Constructor''' has the same name as the 'class name' to which it belongs.
 
+
 
+
+
  
 
|-
 
|-
 
| 03:38
 
| 03:38
'''Constructors''' are also similar to methods but there are some important differences.
+
|  Constructors are also similar to '''methods''' but there are some important differences.
  
 
|-
 
|-
Line 169: Line 148:
 
|-
 
|-
 
|  03:51  
 
|  03:51  
| This is because the '''constructor''', that we defined is same as having no '''constructor.'''
+
| This is because the '''constructor'''  that we defined is same as having no '''constructor.'''
  
 
|-
 
|-
 
|  03:58
 
|  03:58
| But here no default '''constructor''' is created because we have defined a '''constructor.'''
+
| But here, no default '''constructor''' is created because we have defined a '''constructor.'''
  
 
|-
 
|-
 
|  04:06
 
|  04:06
|  Now lets give values to our variables.
+
|  Now, let's give values to our variables.
  
 
|-
 
|-
 
|  04:11
 
|  04:11
| So inside the '''constructor''' type '''''roll_number'''''  ''equal'' ''to'' ''ten'' semicolon.
+
| So, inside the '''constructor''' type: '''roll_number''' equal to ten semicolon.
  
 
|-
 
|-
 
|  04:25
 
|  04:25
| And '''''name'''''    ''equal'' ''to'' within double ''quotes '''Raman'''''
+
| And '''name''' equal to within double quotes '''Raman'''.
  
 
|-
 
|-
Line 193: Line 172:
 
|-
 
|-
 
| 04:43  
 
| 04:43  
|  We see in the output that the '''roll_number''' value is '''ten''' and '''name''' is Raman.
+
|  We see in the output that the '''roll_number''' is '''ten''' and the '''name''' is Raman.
  
 
|-
 
|-
 
|  04:50
 
|  04:50
| So the '''constructor''' initializes the instance field.
+
| So, the '''constructor''' initializes the '''instance field'''.
  
 
|-
 
|-
 
|  04:55
 
|  04:55
|  Now let us see some difference between  '''method''' and a '''constructor'''.
+
|  Now, let us see some differences between  '''method''' and a '''constructor'''.
  
 
|-
 
|-
 
|  05:01
 
|  05:01
| '''Constructor''' does not have  a return type.
+
| '''Constructor''' does not have  a '''return''' type.
  
 
|-
 
|-
 
|  05:05
 
|  05:05
|Whereas '''Method''' has a return type.
+
|whereas '''method''' has a return type.
  
 
|-
 
|-
Line 217: Line 196:
 
|-
 
|-
 
|  05:16
 
|  05:16
|Whereas the  '''Method''' is called using the '''dot''' operator.
+
|whereas the  '''method''' is called using the '''dot''' operator.
  
 
|-
 
|-
 
|  05:21
 
|  05:21
| So this were some differences between '''constructor''' and '''method.'''
+
| So, these were some differences between '''constructor''' and '''method.'''
  
 
|-
 
|-
 
|  05:29
 
|  05:29
|   So in this tutorial, we have learnt  
+
| So, in this tutorial, we have learnt:
  
 
|-
 
|-
 
|  05:32  
 
|  05:32  
| About the default constructor.
+
|About the default '''constructor'''.
 
|-
 
|-
 
|  05:34
 
|  05:34
| To define a contructor.
+
|To define a '''constructor'''.
 
|-
 
|-
 
|  05:36
 
|  05:36
| And Differences between '''method''' and '''constructor.'''
+
|And Differences between '''method''' and '''constructor.'''
 
+
 
+
  
 
|-
 
|-
 
|  05:41
 
|  05:41
|  For self assessment,  
+
|  For self assessment, create a '''class''' '''Employee''' with variables and a  '''method''' to display variables.
 
+
|-
+
|  05:42
+
| Create a class Employee with variables and a  method to display variables.
+
  
 
|-
 
|-
 
|  05:47
 
|  05:47
| And Create a constructor for the class Employee.  
+
| And create a '''constructor''' for the class '''Employee'''.  
  
 
|-
 
|-
 
|  05:52
 
|  05:52
|  To know more about the Spoken Tutorial Project
+
|  To know more about the Spoken Tutorial Project,
 
|-
 
|-
 
|  05:54
 
|  05:54
Watch the video available at [http://spoken-tutorial.org/What_is_a_Spoken_Tutorial http://spoken-][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial tutorial.org/What_is_a_Spoken_Tutorial]
+
watch the video available at http://spoken-tutorial.org/What_is_a_Spoken_Tutorial.
 +
 
 
|-
 
|-
 
|  06:00
 
|  06:00
|  It summarizes the Spoken Tutorial project  
+
|  It summarizes the Spoken Tutorial project.
  
 
|-
 
|-
 
|  06:03
 
|  06:03
| 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.
 
+
 
+
  
 
|-
 
|-
 
|  06:06
 
|  06:06
|  The Spoken Tutorial Project Team
+
|  The Spoken Tutorial project team:
  
 
|-
 
|-
 
|  06:08
 
|  06:08
| Conducts workshops using spoken tutorials  
+
| Conducts workshops using spoken tutorials.
  
 
|-
 
|-
 
|  06:11
 
|  06:11
|  Gives certificates to those who pass an online test  
+
|  Gives certificates to those who pass an online test.
  
 
|-
 
|-
Line 285: Line 257:
 
|-
 
|-
 
| 06:20
 
| 06:20
|  Spoken Tutorial Project is a part of the Talk to a Teacher project  
+
|  Spoken Tutorial project is a part of the Talk to a Teacher project.
  
 
|-
 
|-
 
|  06:24
 
|  06:24
|  It is supported by the National Mission on Education through ICT, MHRD, Government of India  
+
|  It is supported by the National Mission on Education through ICT, MHRD, Government of India.
  
 
|-
 
|-
 
|  06:29
 
|  06:29
| More information on this Mission is available at  
+
| More information on this mission is available at: http://spoken-tutorial.org/NMEICT-Intro.  
 
+
  [http://spoken-tutorial.org/NMEICT-Intro http://spoken-tutorial.org/NMEICT-Intro]
+
 
+
 
+
  
 
|-
 
|-
 
|  06:38
 
|  06:38
|This brings us tothe end of the tutorial.
+
|This brings us to the end of the tutorial.
  
 
|-
 
|-
Line 309: Line 277:
 
|-
 
|-
 
|  06:42
 
|  06:42
| This is Prathamesh Salunke signing off.  Jai Hind.  
+
| This is Prathamesh Salunke, signing off.  Jai Hind.  
  
 
|}
 
|}

Latest revision as of 15:27, 28 March 2017

Time Narration
00:02 Welcome to the Spoken Tutorial on Default constructor in java.
00:07 In this tutorial, we will learn:
00:10 About the default constructor.
00:12 And to create a constructor.
00:15 Here we are using:

Ubuntu version 11.10 Java Development Environment jdk 1.6 and Eclipse 3.7.0

00:26 To follow this tutorial, you must know
00:29 how to create a class and the object of the class in java using eclipse.
00:34 If not, for relevant tutorials, please visit our website which is as shown.http://www.spoken-tutorial.org
00:42 Constructor is used to initialize the instance variables.
00:46 It is called at the creation of new object.
00:50 Let us now see how a constructor is defined in java.
00:55 So, in the eclipse, I have already created a java file Student.java.
01:02 In the Student class we will declare two variables.
01:07 So type int roll_number semi-colon and String name semicolon.
01:20 Now let us create a method.
01:22 So, type: void studentDetail().
01:33 Within curly brackets, type: System dot out dot println roll_number;
01:50 Then System dot out dot println name;.
02:03 Now in main method we will call this method.
02:08 So, let us create an object and call the method.
02:14 So, type: Student object name stu equal to new Student().
02:28 Then stu dot method name i.e studentDetail.
02:41 Save and Run the program.
02:46 We see the output 'zero' and 'null'.
02:49 So, the int variable roll_number has been initialized to its default value 'zero'.
02:56 And the String name has been initialized to its default value 'null'.
03:02 If we do not define a constructor then a default constructor is created.
03:08 Default constructor has no parameters.
03:11 It initializes the instance variables to their default value.
03:16 Now let us define a constructor.
03:18 So, type: Student S capital parenthesis and curly brackets.
03:30 Remember, the Constructor has the same name as the 'class name' to which it belongs.
03:38 Constructors are also similar to methods but there are some important differences.
03:44 Save and Run the program.
03:48 We see the same output.
03:51 This is because the constructor that we defined is same as having no constructor.
03:58 But here, no default constructor is created because we have defined a constructor.
04:06 Now, let's give values to our variables.
04:11 So, inside the constructor type: roll_number equal to ten semicolon.
04:25 And name equal to within double quotes Raman.
04:35 Now Save and Run the program.
04:43 We see in the output that the roll_number is ten and the name is Raman.
04:50 So, the constructor initializes the instance field.
04:55 Now, let us see some differences between method and a constructor.
05:01 Constructor does not have a return type.
05:05 whereas method has a return type.
05:10 Constructor is called using the new operator.
05:16 whereas the method is called using the dot operator.
05:21 So, these were some differences between constructor and method.
05:29 So, in this tutorial, we have learnt:
05:32 About the default constructor.
05:34 To define a constructor.
05:36 And Differences between method and constructor.
05:41 For self assessment, create a class Employee with variables and a method to display variables.
05:47 And create a constructor for the class Employee.
05:52 To know more about the Spoken Tutorial Project,
05:54 watch the video available at http://spoken-tutorial.org/What_is_a_Spoken_Tutorial.
06:00 It summarizes the Spoken Tutorial project.
06:03 If you do not have good bandwidth, you can download and watch it.
06:06 The Spoken Tutorial project team:
06:08 Conducts workshops using spoken tutorials.
06:11 Gives certificates to those who pass an online test.
06:14 For more details, please write to contact@spoken-tutorial.org
06:20 Spoken Tutorial project is a part of the Talk to a Teacher project.
06:24 It is supported by the National Mission on Education through ICT, MHRD, Government of India.
06:29 More information on this mission is available at: http://spoken-tutorial.org/NMEICT-Intro.
06:38 This brings us to the end of the tutorial.
06:40 Thanks for joining.
06:42 This is Prathamesh Salunke, signing off. Jai Hind.

Contributors and Content Editors

Gaurav, PoojaMoolya, Sandhya.np14, Sneha