Difference between revisions of "Java/C2/Method-overloading/Gujarati"
From Script | Spoken-Tutorial
Jyotisolanki (Talk | contribs) (Created page with ' {| border=1 || ''Time''' || '''Narration''' |- | 00:01 | Welcome to the Spoken Tutorial on '''method overloading''' in''' java'''. |- | 00:06 | In this tutorial we will l…') |
Jyotisolanki (Talk | contribs) |
||
| Line 8: | Line 8: | ||
|- | |- | ||
| 00:01 | | 00:01 | ||
| − | | | + | |''' java''' મા '''method overloading''' પરના સ્પોકન ટ્યુટોરીયલમાં સ્વાગત છે. . |
|- | |- | ||
| 00:06 | | 00:06 | ||
| − | | | + | | આ ટ્યુટોરીયલમાં આપણે શીખીશું |
|- | |- | ||
| 00:08 | | 00:08 | ||
| − | | What is '''method overloading. | + | | What is '''method overloading. શુ છે. |
|- | |- | ||
| 00:10 | | 00:10 | ||
| − | | | + | |અને મેથડ ને ઓવરલોડ કરવું. |
| Line 27: | Line 27: | ||
|- | |- | ||
| 00:13 | | 00:13 | ||
| − | | | + | | અહીં આપણે વાપરી રહ્યા છીએ |
| − | + | ઉબુન્ટુ આવૃત્તિ 11.10 OS | |
| − | + | જાવા ડેવલપમેન્ટ કિટ 1.6 | |
| − | + | એક્લિપ્સ 3.7.0 | |
| − | + | ||
| Line 37: | Line 36: | ||
|- | |- | ||
| 00:24 | | 00:24 | ||
| − | | | + | | આ ટ્યુટોરીયલ અનુસરવા માટે તમને ખબર હોવી જોઈએ કે, |
|- | |- | ||
| 00:26 | | 00:26 | ||
| − | | | + | |કેવી રીતે '''methods ''' બનાવવું અને |
|- | |- | ||
| 00:29 | | 00:29 | ||
| − | | | + | |એક્લીપ્સ ના ઉપયોગ વડે જવા મા '''constructor''' ઓવરલોડ કરવું. |
|- | |- | ||
| 00:32 | | 00:32 | ||
| − | | | + | | જો નથી, તો સંદર્ભિત ટ્યુટોરીયલો માટે દર્શાવેલ અમારી વેબસાઈટનો સંદર્ભ લો, |
| − | + | '''(http://www.spoken-tutorial.org)''' | |
|- | |- | ||
| 00:39 | | 00:39 | ||
| − | | | + | |'''method overloading'''શુ છે? |
| + | |||
|- | |- | ||
| 00:42 | | 00:42 | ||
| − | | | + | | એક ક્લાસ મા સમાન નામથી બે અથવા વધુ મેથાડોને વ્યાખ્યિત કરો. |
|- | |- | ||
| 00:46 | | 00:46 | ||
| − | | | + | |તે ક્રમમા અથવા પેરામીટરોના પ્રકારો મા જુદા પડવા જોઈએ. |
|- | |- | ||
| 00:50 | | 00:50 | ||
| − | | | + | |તે મેથડ ને '''overloaded methods''' કહેવાય છે. |
|- | |- | ||
| 00:54 | | 00:54 | ||
| − | | | + | |પ્રક્રિયા ને '''method''' '''overloading'''કહેવાય છે . |
|- | |- | ||
| 00:57 | | 00:57 | ||
| − | | | + | | ચાલો હવે જોઈએ '''method'''ને ઓવરલોડ કેવી રીતે કરવું . |
|- | |- | ||
| 01:00 | | 01:00 | ||
| − | | | + | |એક્લીપ્સ મા મારી પાસે '''Addition''' ક્લાસ છે. |
|- | |- | ||
| 01:06 | | 01:06 | ||
| − | | | + | |ક્લાસની અંદર આપને બે ઈન્ટીજર વેરીએબલો જાહેર કરીશું. |
|- | |- | ||
| 01:10 | | 01:10 | ||
| − | | | + | |તો ટાઈપ કરો '''''int''''' '''''a''''' ''બરાબર '''10''' અને '''int''' '''b''' બરાબર'''5''.''' |
|- | |- | ||
| 01:19 | | 01:19 | ||
| − | | | + | |બે ઈન્ટીજરોને ઉમેરવા માટે ચાલો મથાળ બનાવીએ. |
|- | |- | ||
| 01:23 | | 01:23 | ||
| − | | | + | |તો ટાઈપ કરો ''''' void add ''કૌંસ. |
|- | |- | ||
| 01:30 | | 01:30 | ||
| − | |'' | + | |''છગડીયા કૌંસ મા ટાઈપ કરો '''System''' dot '''out''' dot '''println'''.'' |
|- | |- | ||
| 01:40 | | 01:40 | ||
| − | |'' | + | |''કૌંસ મા '''a+b'''.'' |
|- | |- | ||
| 01:44 | | 01:44 | ||
| − | | | + | |આમ આ મેથડ આપણને બે ઈન્ટીજર વેરીયેબલો નો યોગ આપે છે. |
|- | |- | ||
| 01:50 | | 01:50 | ||
| − | | | + | | ચાલો બીજું એક મેથડ બનાવીએ જે પેરામીટરને લે છે. |
|- | |- | ||
| 01:55 | | 01:55 | ||
| − | | | + | |તો ટાઈપ કરો '''''void addTwoNumbers'''''. |
| + | |||
|- | |- | ||
| 02:04 | | 02:04 | ||
| − | |'' | + | |''કૌંસ મા '''int''' '''num1''' comma '''int''' '''num2.''''' |
|- | |- | ||
| 02:14 | | 02:14 | ||
| − | | | + | | ત્યારબાદ છગડીયા કૌંસમા '''System''' dot '''out''' dot '''println''' '''num1''' plus '''num2.''''' |
|- | |- | ||
| 02:35 | | 02:35 | ||
| − | | | + | |તો મેથડ આપણને બે વેલ્યુ નો યોગ આપશે જે આ મેથડની ટેસ્ટ આર્ગ્યુમેન્ટ પાસ કરે છે. |
| + | |||
|- | |- | ||
| 02:44 | | 02:44 | ||
| − | | | + | | ચાલો બીજું એક મેથડ બનાવીએ જે બે પેરામીટર લે છે. |
|- | |- | ||
| 02:49 | | 02:49 | ||
| − | | | + | |તો '''Main''' મેથડમા ટાઈપ કરો '''''Addition i.e the class name ''''' '''''obj''' બરાબર '''new''' '''Addition''' કૌંસ'' અર્ધવિરામ. |
|- | |- | ||
| 03:13 | | 03:13 | ||
| − | | | + | |ત્યારબાદ'''Obj.add''' |
|- | |- | ||
| 03:18 | | 03:18 | ||
| − | | | + | |અને '''''Obj.addTwonumbers'''કૌંસમા.'' |
|- | |- | ||
| 03:31 | | 03:31 | ||
| − | | | + | |અને આપણેબે આર્ગ્યુમેન્ટ પસાર કરીશું. |
|- | |- | ||
| 03:33 | | 03:33 | ||
| − | | | + | |ધારો કે જો આપણે ફ્લોટિંગ પોઈન્ટ વેલ્યુઓ ને પસાર કરીએ છે. |
|- | |- | ||
| 03:37 | | 03:37 | ||
| − | | | + | |તો ટાઈપ કરો '''2.5''' અર્ધવિરામ અને ઈન્ટીજર '''3'''. |
|- | |- | ||
| 03:45 | | 03:45 | ||
| − | | | + | | આપણને એક એરર મળે છે જે દર્શાવે છે ,''' the method addTwoNumbers int comma int of the class '''આર્ગ્યુમેન્ટ '''double comma int'''માટે લાગુ થતી નથી. |
|- | |- | ||
| 03:57 | | 03:57 | ||
| − | | | + | | તો આપણે શુ કરીશું કે મેથડમા '''int''' ના બદલે આપણે' ''double'''આપીશું . |
|- | |- | ||
| 04:06 | | 04:06 | ||
| − | | | + | |તેથી'''''int'''' ને '''''double'''''થી બદલી કરો. ફાઇલ સંગ્રહિત કરો. |
|- | |- | ||
| 04:12 | | 04:12 | ||
| − | | | + | | આપણે જોઈએ છે કે એરર ઉકેલાઈ ગયો છે. |
|- | |- | ||
| 04:17 | | 04:17 | ||
| − | | | + | |આપણે એ પણ જણીએ છીએ કે''' java'''ઈમ્પ્લીસીટી '''int''' ને '''double'' મા બદલે છે. |
|- | |- | ||
| 04:24 | | 04:24 | ||
| − | | | + | |તેથી અહી આપણે ઈન્ટીજર આર્ગ્યુમેન્ટોને પણ પસાર કરી શકે છે. |
| − | + | ||
|- | |- | ||
| 04:28 | | 04:28 | ||
| − | | | + | | હવે પ્રોગ્રામને '''સેવ ''' અને '''રન'''કરો |
|- | |- | ||
| 04:32 | | 04:32 | ||
| − | | | + | |આઉટપુટમા આપણે બે ઈન્ટીજર નો યોગ જોઈએ છે. |
|- | |- | ||
| 04:37 | | 04:37 | ||
| − | | | + | |અને બે સ્ખ્યાત્મ્ક આર્ગ્યુમેન્ટો નો યોગ જે આપણે પસાર કરી હતી. |
|- | |- | ||
Revision as of 15:50, 4 September 2013
| Time' | Narration |
| 00:01 | java મા method overloading પરના સ્પોકન ટ્યુટોરીયલમાં સ્વાગત છે. . |
| 00:06 | આ ટ્યુટોરીયલમાં આપણે શીખીશું |
| 00:08 | What is method overloading. શુ છે. |
| 00:10 | અને મેથડ ને ઓવરલોડ કરવું.
|
| 00:13 | અહીં આપણે વાપરી રહ્યા છીએ
ઉબુન્ટુ આવૃત્તિ 11.10 OS જાવા ડેવલપમેન્ટ કિટ 1.6 એક્લિપ્સ 3.7.0
|
| 00:24 | આ ટ્યુટોરીયલ અનુસરવા માટે તમને ખબર હોવી જોઈએ કે, |
| 00:26 | કેવી રીતે methods બનાવવું અને |
| 00:29 | એક્લીપ્સ ના ઉપયોગ વડે જવા મા constructor ઓવરલોડ કરવું.
|
| 00:32 | જો નથી, તો સંદર્ભિત ટ્યુટોરીયલો માટે દર્શાવેલ અમારી વેબસાઈટનો સંદર્ભ લો, |
| 00:39 | method overloadingશુ છે? |
| 00:42 | એક ક્લાસ મા સમાન નામથી બે અથવા વધુ મેથાડોને વ્યાખ્યિત કરો. |
| 00:46 | તે ક્રમમા અથવા પેરામીટરોના પ્રકારો મા જુદા પડવા જોઈએ. |
| 00:50 | તે મેથડ ને overloaded methods કહેવાય છે. |
| 00:54 | પ્રક્રિયા ને method overloadingકહેવાય છે . |
| 00:57 | ચાલો હવે જોઈએ methodને ઓવરલોડ કેવી રીતે કરવું . |
| 01:00 | એક્લીપ્સ મા મારી પાસે Addition ક્લાસ છે. |
| 01:06 | ક્લાસની અંદર આપને બે ઈન્ટીજર વેરીએબલો જાહેર કરીશું. |
| 01:10 | તો ટાઈપ કરો int a બરાબર 10 અને int b બરાબર5. |
| 01:19 | બે ઈન્ટીજરોને ઉમેરવા માટે ચાલો મથાળ બનાવીએ. |
| 01:23 | તો ટાઈપ કરો void add કૌંસ. |
| 01:30 | છગડીયા કૌંસ મા ટાઈપ કરો System dot out dot println. |
| 01:40 | કૌંસ મા a+b. |
| 01:44 | આમ આ મેથડ આપણને બે ઈન્ટીજર વેરીયેબલો નો યોગ આપે છે. |
| 01:50 | ચાલો બીજું એક મેથડ બનાવીએ જે પેરામીટરને લે છે. |
| 01:55 | તો ટાઈપ કરો void addTwoNumbers. |
| 02:04 | કૌંસ મા int num1 comma int num2. |
| 02:14 | ત્યારબાદ છગડીયા કૌંસમા System dot out dot println num1 plus num2. |
| 02:35 | તો મેથડ આપણને બે વેલ્યુ નો યોગ આપશે જે આ મેથડની ટેસ્ટ આર્ગ્યુમેન્ટ પાસ કરે છે. |
| 02:44 | ચાલો બીજું એક મેથડ બનાવીએ જે બે પેરામીટર લે છે. |
| 02:49 | તો Main મેથડમા ટાઈપ કરો Addition i.e the class name obj બરાબર new Addition કૌંસ અર્ધવિરામ. |
| 03:13 | ત્યારબાદObj.add |
| 03:18 | અને Obj.addTwonumbersકૌંસમા. |
| 03:31 | અને આપણેબે આર્ગ્યુમેન્ટ પસાર કરીશું. |
| 03:33 | ધારો કે જો આપણે ફ્લોટિંગ પોઈન્ટ વેલ્યુઓ ને પસાર કરીએ છે. |
| 03:37 | તો ટાઈપ કરો 2.5 અર્ધવિરામ અને ઈન્ટીજર 3. |
| 03:45 | આપણને એક એરર મળે છે જે દર્શાવે છે , the method addTwoNumbers int comma int of the class આર્ગ્યુમેન્ટ double comma intમાટે લાગુ થતી નથી. |
| 03:57 | તો આપણે શુ કરીશું કે મેથડમા int' ના બદલે આપણે' doubleઆપીશું . |
| 04:06 | તેથીint' ને doubleથી બદલી કરો. ફાઇલ સંગ્રહિત કરો. |
| 04:12 | આપણે જોઈએ છે કે એરર ઉકેલાઈ ગયો છે. |
| 04:17 | આપણે એ પણ જણીએ છીએ કે' javaઈમ્પ્લીસીટી int ને double મા બદલે છે. |
| 04:24 | તેથી અહી આપણે ઈન્ટીજર આર્ગ્યુમેન્ટોને પણ પસાર કરી શકે છે. |
| 04:28 | હવે પ્રોગ્રામને સેવ અને રનકરો |
| 04:32 | આઉટપુટમા આપણે બે ઈન્ટીજર નો યોગ જોઈએ છે. |
| 04:37 | અને બે સ્ખ્યાત્મ્ક આર્ગ્યુમેન્ટો નો યોગ જે આપણે પસાર કરી હતી. |
| 04:43 | Now we see that both the method performs same operation. |
| 04:50 | The difference is that the first method has no parameter. While the second method has parameters. |
| 05:00 | So in such case java provides us with method overloading. |
| 05:05 | So what we do is give same name to both the methods. |
| 05:09 | So replace addTwoNumbers with add also change here. |
| 05:29 | We will define one more method with same opearation. |
| 05:33 | So type void add. |
| 05:38 | AndWithin parentheses int n1 comma int n2 comma int n3. |
| 05:51 | So we have given three parameters. |
| 05:54 | One Within curly brackets System dot out dot println. |
| 06:03 | Within parentheses n1 plus n2 plus n3. |
| 06:11 | So this method will give sum of three numbers. |
| 06:17 | let us call this method. |
| 06:19 | So type obj dot add 1 comma 5 comma 4 |
| 06:35 | Save' and Run |
| 0639 | In the output we see the sum of three number i.e10 |
| 06:47 | So Java compiler overloads the proper method depending on the parameters. |
| 06:52 | It checks the number and type of parameter passed |
| 06:57 | So as a programmer we dont have worry about the method name. |
| 07:01 | Nor even the type or number of argument we passed. |
| 07:05 | We can create one more method which append strings. |
| 07:11 | So we will create one more overload method |
| 07:15 | type void add String s1 comma String s2. |
| 07:29 | Within curly brackets System dot out dot println. |
| 07:41 | Within parentheses s1 plus s2. |
| 07:45 | And we will call this method. |
| 07:50 | So type obj dot add. |
| 07:55 | Within parentheses in double quotes Hello comma in double quotes space World. |
| 08:07 | Now Save and Run the program. |
| 08:12 | So in the output we see Hello space World. |
| 08:16 | So the add method with two string arguments, appends the string. |
| 08:21 | Suppose now we declare add method with return type. |
| 08:27 | So type int add parentheses no parameter and curly brackets. |
| 08:40 | We get an error it states that duplicate method add in type addition |
| 08:48 | This is because we have already declared a method add with no parameters. |
| 08:54 | So remember that to overload method the parameters must differ. |
| 08:5 | Having different return types will not overload the method. |
| 09:03 | So remove this method and Save the file. |
| 09:09 | This is how method overloading is done in java |
| 09: 16 | So in this tutorial we learnt, |
| 09:18 | About method overloading. |
| 09:20 | To overload method. |
| 09:22 | And advantage of method overloading. |
| 09:25 | For self assessment, create a method subtract that subtract that number |
| 09:31 | Overload it.
|
| 09:33 | To know more about the Spoken Tutorial Project |
| 09:36 | Watch the video available at http://spoken-tutorial.org/What_is_a_Spoken_Tutorial |
| 09:42 | It summarizes the Spoken Tutorial project |
| 09:45 | If you do not have good bandwidth, you can download and watch it
|
| 09:48 | The Spoken Tutorial Project Team |
| 09:50 | Conducts workshops using spoken tutorials |
| 09:52 | Give certificates to those who pass an online test |
| 09:56 | For more details, please write to contact@spoken-tutorial.org
|
| 10:01 | Spoken Tutorial Project is a part of the Talk to a Teacher project |
| 10:05 | It is supported by the National Mission on Education through ICT, MHRD, Government of India |
| 10:11 | More information on this Mission is available at
http://spoken-tutorial.org/NMEICT-Intro
|
| 10:19 | We have come to the end of this tutorial. |
| 10:21 | Thanks for joining. |
| 10:22 | This is Prathamesh Salunke signing off. Jai Hind. |