Difference between revisions of "Java/C2/Parameterized-constructors/Gujarati"
From Script | Spoken-Tutorial
| Line 214: | Line 214: | ||
|- | |- | ||
| 06:00 | | 06:00 | ||
| − | | | + | |ચાલો પેરામીટરાઈઝ કન્સ્ટ્રક્ટર કોલ કરતી વખતે આવતી, સામાન્ય એરર જોઈએ. |
| − | + | ||
|- | |- | ||
| 06:07 | | 06:07 | ||
| − | | | + | |ધારો કે આપણે કન્સ્ટ્રક્ટરમાં એક આરગયુંમેન્ટ પાસ કર્યું છે. |
|- | |- | ||
| 06:11 | | 06:11 | ||
| − | | | + | | તો '''''Raju''''' રદ કરો. |
|- | |- | ||
| 06:15 | | 06:15 | ||
| − | | | + | | આપણને એક એરર મળે છે, જે કહે છે, '''“The constructor Student with parameter (int) is undefined.”''' |
|- | |- | ||
| 06:24 | | 06:24 | ||
| − | | | + | |તો આરગયુંમેન્ટની સંખ્યા, પેરામીટરની સંખ્યા સાથે મેચ થવું જોઈએ. |
|- | |- | ||
| 06:30 | | 06:30 | ||
| − | | | + | |અહીં આપણે ફરીથી '''''Raju''''' લખીશું અને એરર ઉકેલીશું. |
| + | |||
|- | |- | ||
| 06:36 | | 06:36 | ||
| − | | | + | | વૈકલ્પિક રીતે, આપણે એક પેરામીટર સાથે બીજું '''કન્સ્ટ્રક્ટર''' વ્યાખ્યાયિત કરી શકીએ છીએ. |
|- | |- | ||
Revision as of 12:58, 3 September 2013
| Time' | Narration |
| 00:02 | પેરામીટરાઈઝ કન્સ્ટ્રક્ટર પરના સ્પોકન ટ્યુટોરીયલમાં તમારું સ્વાગત છે. |
| 00:08 | આ ટ્યુટોરીયલમાં આપને શીખીશું, |
| 00:10 | પેરામીટરાઈઝ કન્સ્ટ્રક્ટર વિષે, |
| 00:13 | અને પેરામીટરાઈઝ કન્સ્ટ્રક્ટર બનાવવા માટે |
| 00:17 | અહીં આપણે,
|
| 00:29 | આ ટ્યુટોરીયલ અનુસરવા માટે તમને ખબર હોવી જોઈએ કે, |
| 00:32 | એક્લીપ્સની મદદથી જાવામાં ડીફોલ્ટ કન્સ્ટ્રકટર કેવી રીતે બનાવવું. |
| 00:37 | જો નહી તો સંબંધિત ટ્યુટોરીયલ માટે નીચે દર્શાવેલ અમારી વેબસાઈટ જુઓ,
(http://www.spoken-tutorial.org) |
| 00:44 | પેરામીટરાઈઝ કન્સ્ટ્રક્ટર શું છે? |
| 00:48 | કન્સ્ટ્રક્ટર જેને પેરામીટર હોય જે તે પેરામીટરાઈઝ કન્સ્ટ્રક્ટર કહેવાય છે. |
| 00:55 | તેને એક અથવા એક કરતાં વધુ પેરામીટર હોઈ શકે છે. |
| 00:59 | ચાલો હવે પેરામીટરાઈઝ કન્સ્ટ્રક્ટર બનાવીએ. |
| 01:03 | તો એક્લીપ્સમાં, મારી પાસે Student.java ફાઈલ છે. |
| 01:09 | આપણે આ ફાઈલ અગાઉના ટ્યુટોરીયલમાં બનાવી હતી. |
| 01:15 | હવે કન્સ્ટ્રક્ટર અંદર આપણે વેરીયેબલોની મૂળભૂત વેલ્યુ આપીશું. |
| 01:21 | તો ten ના બદલે roll_number ઇકવલ' ટુ ઝીરો . |
| 01:27 | અને Raman ના બદલે,name ઇકવલ ટુ null. |
| 01:33 | પછી ટાઇપ કરો, System dot out dot println I am a default constructor. |
| 01:55 | તો આપણે કોઈ પણ પેરામીટર્સ વગર કન્સ્ટ્રક્ટર બનાવ્યું છે. |
| 02:00 | જાવામાં, આવા કન્સ્ટ્રક્ટર ને ડીફોલ્ટ કન્સ્ટ્રક્ટર કહેવામાં આવે છે. |
| 02:07 | હવે આપણે બીજું કન્સ્ટ્રક્ટર બનાવીશું. |
| 02:11 | તો ટાઇપ કરો, Student કૌસ. |
| 02:17 | કૌંસ અંદર int the_roll_number અલ્પવિરામ String the_name. |
| 02:36 | તો આપણે શું કર્યું છે, એક કન્સ્ટ્રક્ટર પેરામીટર્સ સાથે જાહેર કર્યું છે. |
| 02:43 | કન્સ્ટ્રક્ટર નું નામ સ્ટુડન્ટ એ ક્લાસ નામ છે. |
| 02:49 | કૌસ અંદર આપણે કન્સ્ટ્રક્ટર માટે બે પેરામીટર્સ આપ્યા છે. |
| 02:57 | આપણે કન્સ્ટ્રક્ટર માટે કેટલા પણ પેરામીટર્સ આપી શકીએ છીએ. |
| 03:02 | હવે કર્લી કૌસ અંદર ટાઇપ કરો, |
| 03:05 | System dot out dot println I am a parameterized constructor |
| 03:29 | પછી, roll_number ઇકવલ ટુ the_roll_number. |
| 03:43 | અને name ઇકવલ ટુ the_name. |
| 03:53 | તો આપણે પેરામીટર્સ સાથે કન્સ્ટ્રક્ટર બનાવ્યું છે. |
| 03:58 | હવે ચાલો આ કન્સ્ટ્રક્ટર કોલ કરીએ, |
| 04:02 | તો મેઈન મેથડમાં ટાઇપ કરો; student stu2 ઇકવલ ટુ' new student, કૌસ અંદર, 11 અલ્પવિરામ, ડબલ અવતરણ ચિહ્ન અંદર Raju |
| 04:28 | ચાલો studentDetail મેથડ કોલ કરીએ. |
| 04:31 | તો ટાઇપ કરો,stu2.studentDetail. |
| 04:38 | પ્રોગ્રામ Save અને Run કરો. |
| 04:44 | આપણે કન્સોલ પર આઉટપુટ જોઈએ છીએ. |
| 04:48 | પ્રથમ ડિફૉલ્ટ કન્સ્ટ્રક્ટર કોલ કરવામાં આવે છે. |
| 04:52 | તે વેરિયેબલને તેની ડિફોલ્ટ વેલ્યુથી ઈનીશ્યલાઈઝ કરે છે. |
| 04:56 | પછી પેરામીટરાઈઝ કન્સ્ટ્રક્ટર કોલ કરવામાં આવે છે. |
| 05:00 | તે આરગ્યુંમેન્ટ તરીકે પાસ થતી વેલ્યુ દ્વારા વેરીયેબલો ઈનીશ્યલાઈઝ કરે છે. |
| 05:05 | તે 11 અને Raju છે. |
| 05:08 | ચાલો જોઈએ પેરામીટરાઈઝ કન્સ્ટ્રક્ટર કેવી રીતે કામ કરે છે. |
| 05:12 | જયારે આપણે પેરામીટરાઈઝ કન્સ્ટ્રક્ટર કોલ કરીએ છીએ, ત્યારે આપણે બે વેલ્યુ પાસ કરીએ છીએ. |
| 05:18 | તેઓ આરગ્યુંમેન્ટ કહેવામાં આવે છે. |
| 05:22 | 11 વેલ્યુ પેરામીટર the_roll_number માં કોપી થઇ છે. |
| 05:31 | અને વેલ્યુ Raju પેરામીટર the_name માં કોપી થઇ છે. |
| 05:41 | પછી the_roll_number ની વેલ્યુ roll_number માં અસાઇન થશે. |
| 05:50 | અને the_name ની વેલ્યુ name માં અસાઇન થશે. |
| 05:55 | તો આપણે આઉટપુટ 11 અને Raju જોઈએ છીએ. |
| 06:00 | ચાલો પેરામીટરાઈઝ કન્સ્ટ્રક્ટર કોલ કરતી વખતે આવતી, સામાન્ય એરર જોઈએ. |
| 06:07 | ધારો કે આપણે કન્સ્ટ્રક્ટરમાં એક આરગયુંમેન્ટ પાસ કર્યું છે. |
| 06:11 | તો Raju રદ કરો. |
| 06:15 | આપણને એક એરર મળે છે, જે કહે છે, “The constructor Student with parameter (int) is undefined.” |
| 06:24 | તો આરગયુંમેન્ટની સંખ્યા, પેરામીટરની સંખ્યા સાથે મેચ થવું જોઈએ. |
| 06:30 | અહીં આપણે ફરીથી Raju લખીશું અને એરર ઉકેલીશું. |
| 06:36 | વૈકલ્પિક રીતે, આપણે એક પેરામીટર સાથે બીજું કન્સ્ટ્રક્ટર વ્યાખ્યાયિત કરી શકીએ છીએ. |
| 06:42 | Let us do that |
| 06:45 | So Student within paranthesis int r number. |
| 07:01 | Inside curly brackets, type System dot out dot println |
| 07:13 | I am a constructor with a single parameter. |
| 07:29 | Then roll_number is equal to r number |
| 07:48 | Save the file. |
| 07:51 | We see that the error is resolved when we define the constructor. |
| 07:58 | Let's Run the program. |
| 08:02 | On the console we see that the roll number is assigned the value 11. |
| 08:08 | While name is null since the constructor takes only one argument. |
| 08:18 | Let us now call back our constructor with two parameters. |
| 08:23 | So type Student stu3 is equal to new Student. |
| 08:40 | 11 comma Raju. |
| 08:46 | ThenStu3 dot studentDetail |
| 08:58 | Suppose here we pass 11 as String, so add double quotes. |
| 09:08 | We get an error. |
| 09:10 | It states that “The constructor Student String commaString is undefined.” |
| 09:17 | So even the datatype of the argument must match with that of the parameter. |
| 09:25 | So now remove the quotes and Save the file. |
| 09:32 | Now we do not see an error. |
| 09:35 | So Run the program. |
| 09:38 | In the output we see three constructors. |
| 09:42 | The first one is the default constructor. |
| 09:45 | The second one is theConstructor with one parameter. |
| 09:50 | And this third one is theConstructor with two parameters. |
| 09:56 | This is how we createParameterised constructor in java.
|
| 10:05 | Why constructor? |
| 10:07 | The variables in a class must be initialized each time an instance is created.
|
| 10:13 | It can be tedious to initialize all the variables.
|
| 10:18 | So java allows objects to initialize themselves when they are created.
|
| 10:25 | This is performed through the use of a constructor. |
| 10:30 | So in this tutorial, we have learnt |
| 10:33 | To create parameterized constructor. |
| 10:36 | Functionality of parameterized constructor. |
| 10:39 | And the advantage of using constructor. |
| 10:44 | For self assessment, create a class Employee. |
| 10:48 | Create constructors with different number of parameters. |
| 10:53 | To know more about the Spoken Tutorial Project |
| 10:56 | Watch the video available at http://spoken-tutorial.org/What_is_a_Spoken_Tutorial |
| 11:02 | It summarizes the Spoken Tutorial project |
| 11:06 | If you do not have good bandwidth, you can download and watch it
|
| 11:10 | The Spoken Tutorial Project Team |
| 11:12 | Conducts workshops using spoken tutorials |
| 11:14 | Gives certificates for those who pass an online test |
| 11:18 | For more details, please write to contact@spoken-tutorial.org
|
| 11:24 | Spoken Tutorial Project is a part of the Talk to a Teacher project |
| 11:28 | It is supported by the National Mission on Education through ICT, MHRD, Government of India |
| 11:34 | More information on this Mission is available at
|
| 11:43 | This brings us to the end of the tutorial. |
| 11:46 | Thanks for joining. |
| 11:47 | This is Prathamesh Salunke signing off.
Jai Hind. |