Difference between revisions of "Java/C2/Non-static-block/Gujarati"
From Script | Spoken-Tutorial
(Created page with ' {| border=1 || ''Time''' || '''Narration''' |- | 00:02 | Welcome to the Spoken Tutorial on '''Non-static block '''in '''java'''. |- | 00:06 | In this tutorial we will learn…') |
|||
Line 4: | Line 4: | ||
|- | |- | ||
| 00:02 | | 00:02 | ||
− | | | + | | '''જાવામાં''' '''નોન સ્ટેટિક બ્લોક''' પરના સ્પોકન ટ્યુટોરીયલમાં તમારું સ્વાગત છે. |
|- | |- | ||
| 00:06 | | 00:06 | ||
− | | | + | | આ ટ્યુટોરીયલ માં આપણે શીખીશું, |
− | + | ||
|- | |- | ||
| 00:08 | | 00:08 | ||
− | | | + | | '''નોન સ્ટેટિક બ્લોક''' વિષે, |
|- | |- | ||
| 00:10 | | 00:10 | ||
− | | | + | | '''નોન સ્ટેટિક બ્લોક''' ક્યારે એક્ઝિક્યુટ થાય છે? |
|- | |- | ||
| 00:13 | | 00:13 | ||
− | | | + | | '''નોન સ્ટેટિક બ્લોક''' નું સરળ ઉદાહરણ |
|- | |- | ||
| 00:16 | | 00:16 | ||
− | | | + | |અને આપણને કન્સ્ટ્રકટર્સની જરૂર શા માટે પડે છે? |
− | + | ||
− | + | ||
|- | |- | ||
| 00:18 | | 00:18 | ||
− | | | + | | અહીં આપણે, |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
+ | * ઉબુન્ટુઆવૃત્તિ 11.10 | ||
+ | * જાવા ડેવલપમેન્ટ એન્વાયર્નમેન્ટ jdk 1.6 | ||
+ | *અને એક્લીપ્સ IDE 3.7.0 નો ઉપયોગ કરી રહ્યા છીએ. | ||
|- | |- | ||
| 00:26 | | 00:26 | ||
− | | | + | |આ ટ્યુટોરીયલ અનુસરવા માટે તમને ખબર હોવી જોઈએ કે, |
|- | |- | ||
| 00:29 | | 00:29 | ||
− | |How to create a '''constructor''' in '''Java''' using '''Eclipse''' | + | |How to create a '''constructor''' in '''Java''' using '''Eclipse''' એક્લીપ્સની મદદથી જાવામાં કન્સ્ટ્રકટર કેવી રીતે બનાવવું. |
|- | |- | ||
| 00:33 | | 00:33 | ||
− | | | + | | જો નહી તો સંબંધિત ટ્યુટોરીયલ માટે નીચે દર્શાવેલ અમારી વેબસાઈટ જુઓ, |
('''http'''://'''www.spoken'''-'''tutorial.org''') | ('''http'''://'''www.spoken'''-'''tutorial.org''') | ||
Line 55: | Line 50: | ||
|- | |- | ||
| 00:38 | | 00:38 | ||
− | | | + | | હવે આપણે '''નોન સ્ટેટિક બ્લોક''' શું છે તે જોઈશું. |
− | + | ||
|- | |- | ||
| 00:42 | | 00:42 | ||
− | | | + | |બે કર્લી કૌંસ વચ્ચે લખાયેલ કોઈ પણ કોડ '''નોન સ્ટેટિક બ્લોક''' છે. |
− | + | ||
|- | |- | ||
|00:46 | |00:46 | ||
− | | | + | | આપણે સીન્ટેક્ષ અહીં જોઈ શકીએ છીએ |
|- | |- |
Revision as of 17:19, 27 August 2013
Time' | Narration |
00:02 | જાવામાં નોન સ્ટેટિક બ્લોક પરના સ્પોકન ટ્યુટોરીયલમાં તમારું સ્વાગત છે. |
00:06 | આ ટ્યુટોરીયલ માં આપણે શીખીશું, |
00:08 | નોન સ્ટેટિક બ્લોક વિષે, |
00:10 | નોન સ્ટેટિક બ્લોક ક્યારે એક્ઝિક્યુટ થાય છે? |
00:13 | નોન સ્ટેટિક બ્લોક નું સરળ ઉદાહરણ |
00:16 | અને આપણને કન્સ્ટ્રકટર્સની જરૂર શા માટે પડે છે? |
00:18 | અહીં આપણે,
|
00:26 | આ ટ્યુટોરીયલ અનુસરવા માટે તમને ખબર હોવી જોઈએ કે, |
00:29 | How to create a constructor in Java using Eclipse એક્લીપ્સની મદદથી જાવામાં કન્સ્ટ્રકટર કેવી રીતે બનાવવું. |
00:33 | જો નહી તો સંબંધિત ટ્યુટોરીયલ માટે નીચે દર્શાવેલ અમારી વેબસાઈટ જુઓ,
(http://www.spoken-tutorial.org) |
00:38 | હવે આપણે નોન સ્ટેટિક બ્લોક શું છે તે જોઈશું. |
00:42 | બે કર્લી કૌંસ વચ્ચે લખાયેલ કોઈ પણ કોડ નોન સ્ટેટિક બ્લોક છે. |
00:46 | આપણે સીન્ટેક્ષ અહીં જોઈ શકીએ છીએ |
00:51 | When is a non-static block executed ? |
00:54 | A non-static block is executedfor each object that is created. |
00:59 | It executes before the constructor's execution.
|
01:04 | It can initialize instance member variables of the class.
|
01:08 | Any other execution like calculation could also be given in the block.
|
01:14 | Now, let us switch to Eclipse and try to use a non-static block. |
01:23 | I have already opened a class named NonStaticTest in Eclipse.
|
01:28 | I also have a created a class named A .
|
01:33 | Now inside class A , I will first create a variable of type int.
|
01:38 | So type int a semicolon, then press Enter
|
01:46 | Within curly brackets type System dot out dot println within brackets and double quotes Non static block of an instance of Class A semicolon.
|
02:12 | Then type System dot out dot println within brackets and double quotes The value of a is plus a semicolon.
|
02:32 | Now we will declare a constructor. |
02:36 | So type public A opening and closing brackets, open the curly brackets press Enter.
|
02:51 | Then type System dot out dot println within brackets and double quotes Constructing object of type A semicolon.
|
03:11 | Then type System dot out dot println within brackets and double quotes The value of a is plus a semicolon.
|
03:35 | Now save this file. |
03:44 | Inside class NonStaticTest in Eclipse let us create an object of the class A.
|
03:53 | So type A space a1 equal to new space A opening and closing brackets semicolon
|
04:08 | Next line we will create one more object of class A. |
04:12 | So type A space a2 equal to new space A opening and closing brackets semicolon.
|
04:25 | Now Save and run the file. So press Ctrl &S and Ctrl &F11 keys
|
04:32 | We get the output as follows: |
04:35 | As we can see when the first object is created, the non-static block is executed.
|
04:45 | non-static block of an instance of class A and the instance variable A is initialized to 0.
|
04:53 | Only after that the constructor is executed. Constructing object of type A
|
05:02 | And here the instance variable is again initialized to 0.
|
05:07 | Then again when the second object is created, the non-static block is executed.
|
05:16 | This process is repeated. |
05:20 | We can have multiple non-static blocks in a class.
|
05:25 | In this case they execute in the sequence in which they appear in the class.
|
05:30 | We can try that now.
|
05:34 | Include one more block after the first one in class A. |
05:43 | So again type inside curly brackets.
|
05:47 | System dot out dot println within brackets and double quotes Second Non static block of an instance of Class A semicolon.
|
06:08 | Then type System dot out dot println within brackets and double quotes The value of a is plus a semicolon.
|
06:30 | Now save this file ,press Ctrl & S key simultaneously then press Ctrl & F11 to run the program. |
06:44 | We get the output as follows. |
06:48 | we see that after the first block is executed, the second is executed.
|
06:58 | Only then the constructor is executed. |
07:07 | Now you might feel why do we need constructors.
|
07:10 | The answer is we don't need the default constructor.
|
07:15 | But the non-static block cannot be parameterized.
|
07:18 | You cannot have objects taking values from out side.
|
07:22 | So non-static block is not a substitute for constructor. |
07:27 | So let us summarizes |
07:29 | In this tutorial we learnt :
|
07:32 | About non-static block and how to use this block.
|
07:35 | For self assessment, |
07:36 | create a class named B. |
07:39 | Create a non-static block and a constructor as shown in the tutorial. |
07:44 | Create an object of class B in the class NonStaticTest already created. |
07:49 | Check the output.
|
07:51 | To know more about the Spoken Tutorial Project |
07:53 | Watch the video available at http://spoken-tutorial.org/What_is_a_Spoken_Tutorial |
07:56 | It summarizes the Spoken Tutorial project |
08:00 | If you do not have good bandwidth, you can download and watch it
|
08:03 | The Spoken Tutorial Project Team |
08:06 | Conducts workshops using spoken tutorials |
08:08 | Gives certificates for those who pass an online test |
08:12 | For more details, please write to contact@spoken-tutorial.org
|
08:18 | Spoken Tutorial Project is a part of the Talk to a Teacher project |
08:22 | It is supported by the National Mission on Education through ICT, MHRD, Government of India |
08:28 | More information on this Mission is available at
|
08:37 | Thus we have come to the end of this tutorial. |
08:40 | This is Arya Ratish from IIT BOmbay signing off. Thanks for joining.
|