Difference between revisions of "Java/C3/Calling-methods-of-the-superclass/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with " {| border=1 | <center>'''Time'''</center> | <center>'''Narration'''</center> |- | 00:01 | Welcome to the spoken-tutorial on '''Calling methods of the super class.''' |- |...")
 
 
(7 intermediate revisions by 3 users not shown)
Line 7: Line 7:
 
|-
 
|-
 
| 00:01
 
| 00:01
| Welcome to the spoken-tutorial on '''Calling methods of the super class.'''
+
| Welcome to the '''spoken-tutorial''' on '''Calling methods of the super class.'''
  
 
|-
 
|-
 
| 00:07
 
| 00:07
| In this tutorial we will learn when to use the '''super keyword'''
+
| In this tutorial, we will learnwhen to use the '''super keyword'''
  
 
|-
 
|-
 
| 00:13
 
| 00:13
| How to call '''methods '''of the '''super class'''
+
| How to call '''methods '''of the '''super class'''
  
 
|-
 
|-
 
| 00:17
 
| 00:17
| How to invoke the '''constructor '''of the '''super class'''
+
| How to invoke the '''constructor '''of the '''super class'''.
  
 
|-
 
|-
 
| 00:22
 
| 00:22
| Here we are using
+
| Here we are using: '''Ubuntu Version 12.04''' ,'''JDK 1.7''' ,'''Eclipse 4.3.1'''
 
+
* '''Ubuntu Version 12.04'''
+
* '''JDK 1.7'''
+
* '''Eclipse 4.3.1'''
+
  
 
|-
 
|-
Line 43: Line 39:
 
|-
 
|-
 
| 00:51
 
| 00:51
| A '''subclass '''can use a '''superclass''' '''data '''or '''method '''using the '''super keyword.'''
+
| A '''subclass '''can use a '''superclass''' '''data '''or '''method '''using the '''super''' keyword.
  
 
|-
 
|-
 
| 00:58
 
| 00:58
| The '''super keyword ''':
+
| The '''super''' keyword :
* refers to the '''instance variable''' of the '''parent class.'''
+
 
* is used to invoke '''parent class constructor'''.
+
refers to the '''instance variable''' of the '''parent class,'''
* is used to invoke '''parent class method.'''
+
 
 +
is used to invoke '''parent class constructor''',
 +
 
 +
is used to invoke '''parent class method.'''
  
 
|-
 
|-
Line 62: Line 61:
 
|-
 
|-
 
| 01:22
 
| 01:22
| Now, come to the '''getDetails() method.'''
+
| Now, come to the '''getDetails()''' method.
  
 
|-
 
|-
Line 78: Line 77:
 
|-
 
|-
 
| 01:41
 
| 01:41
| We already have a '''getDetails() method '''here'''.'''
+
| We already have a '''getDetails()''' method here.
  
 
|-
 
|-
 
| 01:46
 
| 01:46
| This method '''returns '''the '''name '''and '''email.'''
+
| This method returns the '''name '''and '''email.'''
  
 
|-
 
|-
 
| 01:51
 
| 01:51
| So, we can use this '''getDetails() method '''in the '''Manager class.'''
+
| So, we can use this '''getDetails()''' method in the '''Manager class.'''
  
 
|-
 
|-
 
| 01:57
 
| 01:57
| We will call '''getDetails() method '''from the '''Employee class, '''inside the '''Manager class.'''
+
| We will call '''getDetails()''' method from the '''Employee class, '''inside the '''Manager class.'''
  
 
|-
 
|-
 
| 02:04
 
| 02:04
| So, come to the '''getDetails() method ''' in the manager class.
+
| So, come to the '''getDetails() method ''' in the '''manager''' class.
  
 
|-
 
|-
 
| 02:10
 
| 02:10
| Inside the '''return statement '''type '''super dot getDetails() '''''plus slash n '''''Manager of '''''get '''''department.'''
+
| Inside the '''return''' statement, type: '''super dot getDetails()''' ''plus slash'' n '''Manager of getDepartment().'''
  
 
|-
 
|-
 
| 02:22
 
| 02:22
| Now, let me '''run''' the '''program '''
+
| Now, let me '''run''' the program.
  
 
|-
 
|-
 
| 02:25
 
| 02:25
| We can see that we get the '''Manager details.''' thus we can call the method of superclass inside the subclass
+
| We can see that we get the '''Manager''' details. Thus we can call the method of '''superclass''' inside the '''subclass'''.
  
 
|-
 
|-
Line 118: Line 117:
 
|-
 
|-
 
| 02:44
 
| 02:44
| So inside the '''Employee class, '''type  '''public space''' '''Employee '''''within brackets '''''String name, String email_address '''
+
| So, inside the '''Employee class, '''type: '''public''' space '''Employee ''' within brackets '''String name, String email_address '''.
  
 
|-
 
|-
 
| 02:59
 
| 02:59
| Within curly brackets, type '''this dot''' '''name is equal to name semicolon'''. '''this dot''' '''email_address is equal to email_address '''
+
| Within curly brackets, type: '''this dot name is equal to name semicolon''' , '''this dot email_address is equal to email_address'''
  
 
|-
 
|-
 
| 03:17
 
| 03:17
| Now let us comment the '''setter '''and '''getter methods.'''
+
| Now, let us comment the '''setter '''and '''getter''' methods.
  
 
|-
 
|-
 
| 03:23
 
| 03:23
| Inside the '''getDetails() method, '''
+
| Inside the '''getDetails()''' method-  instead of '''getName''', type '''name''' , instead of '''getEmail''', type '''email_address.'''
 
+
* instead of '''getName '''type '''name, '''
+
* instead of '''getEmail '''type '''email_address.'''
+
  
 
|-
 
|-
 
| 03:37
 
| 03:37
| A '''subclass '''inherits all of the '''methods '''and '''variables '''from a '''parent class'''.
+
| A '''subclass '''inherits all of the methods and variables from a '''parent class'''.
  
 
|-
 
|-
 
| 03:44
 
| 03:44
| Note that it does not '''inherit constructors.'''
+
| Note that it does not inherit '''constructors.'''
  
 
|-
 
|-
Line 161: Line 157:
 
|-
 
|-
 
| 04:10
 
| 04:10
| So, type '''public space''' '''Manager '''''within brackets '''''String '''''space '''''name, String space''' '''email ''' underscore '''address, String space''' '''dept '''
+
| So, type: '''public''' ''space'' '''Manager''' within brackets '''String''' ''space '' '''name comma String''' space '''email underscore address comma String''' space '''dept '''.
  
 
|-
 
|-
 
| 04:30
 
| 04:30
|Then within curly brackets, type '''super '''''within brackets '''''name, email underscore address semicolon'''
+
|Then, within curly brackets, type: '''super '''within brackets '''name, email underscore address semicolon'''.
  
 
|-
 
|-
 
| 04:44
 
| 04:44
|Then type, '''department is equal to''' '''dept semicolon'''
+
|Then type: '''department is equal to dept semicolon'''.
  
 
|-
 
|-
 
| 04:51
 
| 04:51
| Here we will comment the '''setter and getter methods.'''
+
| Here we will comment the '''setter''' and '''getter''' methods.
  
 
|-
 
|-
 
| 04:56
 
| 04:56
| Then, in the '''getDetails() method '''type '''department '''instead of '''getDepartment.'''  
+
| Then, in the '''getDetails()''' method type: '''department '''instead of '''getDepartment.'''  
  
 
|-
 
|-
 
| 05:05
 
| 05:05
| Now, come to the '''TestEmployee class.'''
+
| Now, come to the '''TestEmployee''' class.
  
 
|-
 
|-
Line 189: Line 185:
 
|-
 
|-
 
| 05:15
 
| 05:15
| Now, inside the call to the '''Manager constructor '''type ''within quotes '''''Nikkita Dinesh,  abc@gmail.com, Accounts'''
+
| Now, inside the call to the '''Manager constructor''', type: within quotes '''Nikkita Dinesh,  abc@gmail.com, Accounts'''.
  
 
|-
 
|-
 
| 05:32
 
| 05:32
| Now, run the '''program.'''
+
| Now, '''run''' the program.
  
 
|-
 
|-
 
| 05:35
 
| 05:35
| We get the output as shown. We get the '''Manager details.'''
+
| We get the output as shown. We get the '''Manager''' details.
  
 
|-
 
|-
Line 205: Line 201:
 
|-
 
|-
 
| 05:45
 
| 05:45
| In this tutorial we have learnt:
+
| In this tutorial, we have learnt: the '''super keyword ''' ,calling the method of the '''super class '''and invoking constructor of '''super class'''.
 
+
* the '''super keyword '''
+
* calling the method of the '''super class '''and
+
* invoking constructor of '''super class'''
+
  
 
|-
 
|-
 
| 05:56
 
| 05:56
| As an Assignment
+
| As an Assignment-Open the previous assignment. Call the '''Vehicle class run method '''in the '''Bike class.'''
 
+
* Open the previous assignment.
+
* Call the '''Vehicle class run method '''in the '''Bike class.'''
+
  
 
|-
 
|-
 
| 06:04
 
| 06:04
|* The output should be:
+
| The output should be: '''The Vehicle is running.''' '''The Bike is running safely.'''
** '''The Vehicle is running.'''
+
** '''The Bike is running safely.'''
+
  
 
|-
 
|-
 
| 06:10
 
| 06:10
| To know more about the Spoken Tutorial Project, Watch the video available at the following link
+
| To know more about the Spoken Tutorial Project, watch the video available at the following link.
  
 
|-
 
|-
 
| 06:17
 
| 06:17
| It summarizes the Spoken Tutorial project . If you do not have good bandwidth, you can download and watch it
+
| It summarizes the Spoken Tutorial project . If you do not have good bandwidth, you can download and watch it.
  
 
|-
 
|-
 
| 06:26
 
| 06:26
| The Spoken Tutorial Project Team
+
|The Spoken Tutorial Project Team: Conducts workshops using spoken tutorials
 
+
Gives certificates for those who pass an online test. For more details, please write to '''contact at spoken hyphen tutorial dot org'''.
* Conducts workshops using spoken tutorials
+
 
+
* Gives certificates for those who pass an online test
+
 
+
* For more details, please write to contact at spoken hyphen tutorial dot org
+
  
 
|-
 
|-
 
| 06:42
 
| 06:42
| 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:46
 
| 06:46
| 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:54
 
| 06:54
| More information on this Mission is available at http://spoken-tutorial.org/NMEICT- Intro
+
| More information on this mission is available at: '''http://spoken-tutorial.org/NMEICT- Intro'''
  
 
|-
 
|-
 
| 07:05
 
| 07:05
|This is '''Arya Ratish '''from '''IIT Bombay '''signing off. Thanks for joining.
+
|This is Arya Ratish from '''IIT Bombay''', signing off. Thanks for joining.
  
 
|}
 
|}

Latest revision as of 10:36, 3 May 2019


Time
Narration
00:01 Welcome to the spoken-tutorial on Calling methods of the super class.
00:07 In this tutorial, we will learn: when to use the super keyword
00:13 How to call methods of the super class
00:17 How to invoke the constructor of the super class.
00:22 Here we are using: Ubuntu Version 12.04 ,JDK 1.7 ,Eclipse 4.3.1
00:32 To follow this tutorial, you must have basic knowledge of Java and Eclipse IDE.
00:39 You must also have knowledge of subclassing and method overriding in Java.
00:45 If not, for relevant tutorials, please visit our website.
00:51 A subclass can use a superclass data or method using the super keyword.
00:58 The super keyword :

refers to the instance variable of the parent class,

is used to invoke parent class constructor,

is used to invoke parent class method.

01:13 Now, let us go to the IDE and to the project we created earlier.
01:19 Let us go to the Manager class.
01:22 Now, come to the getDetails() method.
01:26 In the return statement, let us remove Name and Email.
01:32 Now, let us come to the Employee class.
01:36 This is the parent class or super class.
01:41 We already have a getDetails() method here.
01:46 This method returns the name and email.
01:51 So, we can use this getDetails() method in the Manager class.
01:57 We will call getDetails() method from the Employee class, inside the Manager class.
02:04 So, come to the getDetails() method in the manager class.
02:10 Inside the return statement, type: super dot getDetails() plus slash n Manager of getDepartment().
02:22 Now, let me run the program.
02:25 We can see that we get the Manager details. Thus we can call the method of superclass inside the subclass.
02:36 Now let us come to the Employee class.
02:41 Let us include a constructor here.
02:44 So, inside the Employee class, type: public space Employee within brackets String name, String email_address .
02:59 Within curly brackets, type: this dot name is equal to name semicolon , this dot email_address is equal to email_address
03:17 Now, let us comment the setter and getter methods.
03:23 Inside the getDetails() method- instead of getName, type name , instead of getEmail, type email_address.
03:37 A subclass inherits all of the methods and variables from a parent class.
03:44 Note that it does not inherit constructors.
03:49 But, constructors can call the non-private constructors of its superclass.
03:55 We do this using the keyword super from the child class constructor.
04:01 We will see that now.
04:04 For that, come to the Manager class. We will include a constructor here.
04:10 So, type: public space Manager within brackets String space name comma String space email underscore address comma String space dept .
04:30 Then, within curly brackets, type: super within brackets name, email underscore address semicolon.
04:44 Then type: department is equal to dept semicolon.
04:51 Here we will comment the setter and getter methods.
04:56 Then, in the getDetails() method type: department instead of getDepartment.
05:05 Now, come to the TestEmployee class.
05:09 Comment the call to the setter methods.
05:15 Now, inside the call to the Manager constructor, type: within quotes Nikkita Dinesh, abc@gmail.com, Accounts.
05:32 Now, run the program.
05:35 We get the output as shown. We get the Manager details.
05:40 In this way, we can call the constructor of the super class.
05:45 In this tutorial, we have learnt: the super keyword ,calling the method of the super class and invoking constructor of super class.
05:56 As an Assignment-Open the previous assignment. Call the Vehicle class run method in the Bike class.
06:04 The output should be: The Vehicle is running. The Bike is running safely.
06:10 To know more about the Spoken Tutorial Project, watch the video available at the following link.
06:17 It summarizes the Spoken Tutorial project . If you do not have good bandwidth, you can download and watch it.
06:26 The Spoken Tutorial Project Team: Conducts workshops using spoken tutorials

Gives certificates for those who pass an online test. For more details, please write to contact at spoken hyphen tutorial dot org.

06:42 Spoken Tutorial Project is a part of the Talk to a Teacher project.
06:46 It is supported by the National Mission on Education through ICT, MHRD, Government of India.
06:54 More information on this mission is available at: http://spoken-tutorial.org/NMEICT- Intro
07:05 This is Arya Ratish from IIT Bombay, signing off. Thanks for joining.

Contributors and Content Editors

Jyotisolanki, PoojaMoolya, Pratik kamble, Sandhya.np14