8.15 Anonymous Object in Java

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 พ.ย. 2024

ความคิดเห็น • 296

  • @SagarSagar-ro3fj
    @SagarSagar-ro3fj 6 ปีที่แล้ว +34

    I have read java books in dipLoma..then i engg college...attebded one Institute.. then while in job for some months on google..But all bookish...and Nothing worked..but your videos taught me in 2 days .😂😂 u receive the honor of 'SIR'👏👌👍

    • @Epistemer
      @Epistemer 5 ปีที่แล้ว +1

      have you tried " head first java " ?

  • @nynra6584
    @nynra6584 8 ปีที่แล้ว +6

    Explained comprehensively. Thank you Telusko. The reason why most of the Telusko videos are comprehensive is because it illustrates the underlying workings of the concepts of java. And I hope it continues and improves upon this method.

  • @gaurav28ch
    @gaurav28ch 8 ปีที่แล้ว +38

    Incredible explanation of anonymous objects.
    I have browsed through content over your channel. Your videos are way better than anything I have looked elsewhere on TH-cam.

  • @gurunathsingirikonda3468
    @gurunathsingirikonda3468 8 ปีที่แล้ว +28

    the answer is' 0', because after the execution of new A().k=29 it is eligible for garbage collection so when new A().show(); is executed then again a new object for class A is created and the intial vale of variables of class is '0',so the output is '0'

    • @mohanrammanikandan7939
      @mohanrammanikandan7939 5 ปีที่แล้ว +1

      Thank you.
      Excellent explanation for how garbage collection functions.

  • @gamersoul1098
    @gamersoul1098 4 ปีที่แล้ว +20

    sir i think i wasted my money by going to college
    such a great explanation, no any teacher could give great explanation like you

  • @SAIFULISLAM-mn8bs
    @SAIFULISLAM-mn8bs 8 ปีที่แล้ว +13

    now thats called as an explaination really worth a huge round of applause.very nicely explained naveen

  • @aurorasharif4687
    @aurorasharif4687 4 ปีที่แล้ว +1

    more i watch your videos, more amazed i get by ur explanation skill. hats off..

  • @shubhkhushi3826
    @shubhkhushi3826 5 ปีที่แล้ว +7

    Did he just say "Welcome back Aliens" :o ???
    Anyway, this alien is really impressed by your teaching skills. Appreciate your effort. Thanks !

  • @manikantaatchuta6564
    @manikantaatchuta6564 4 ปีที่แล้ว +1

    After watching ur explanations I stopped using Udemy and all.. such a nice explanation.

  • @akshaykumar4-yrb.tech.elec719
    @akshaykumar4-yrb.tech.elec719 3 ปีที่แล้ว +1

    None has ever explained to me so beautifully before.

  • @mdarafatalamleon9721
    @mdarafatalamleon9721 2 ปีที่แล้ว

    our are such a real boss of programming

  • @foton8998
    @foton8998 4 ปีที่แล้ว +1

    It is soo explanatory video for reference object usage what it is doing in the memory. Thank you so much!

  • @IreshDissanayakaM
    @IreshDissanayakaM 6 ปีที่แล้ว +1

    Crystal Clear explanation! I love watching your videos.

  • @AzharAliajju
    @AzharAliajju 4 ปีที่แล้ว +1

    most amazing explanation of anonymous objects.....bravo man..!!!

  • @CultOfJ
    @CultOfJ 4 ปีที่แล้ว +1

    Loved how you explain and moreover I had that same question in-between "when not to use anonymous object" and you guess it correctly and explained, thnx 👍🏻❤️

  • @KrishnaKumar-np3tw
    @KrishnaKumar-np3tw 8 ปีที่แล้ว

    Very nice explanation, found this to be the clearest on the net so far

  • @bholanathjha3961
    @bholanathjha3961 7 ปีที่แล้ว

    sir your way of explaining the things is too good..
    it really helps me a lot..so thank you..

  • @nileshdivekar3127
    @nileshdivekar3127 2 ปีที่แล้ว

    In these 2 lines, when the 1st new A().k = 29 was written, a new object inside the heap memory is invoked.
    Now, right after this, when the 2nd line new A().show got written, again a completely different new object inside the heap memory got created which means the value of 2nd line will be the default value instead of 29

  • @ankitnarwaria7237
    @ankitnarwaria7237 2 ปีที่แล้ว

    Wonderfully explained each and every point.

  • @nirmesh44
    @nirmesh44 6 ปีที่แล้ว

    your way of simple teaching is awesome. I am becoming your fan!

  • @Sushil2874
    @Sushil2874 7 ปีที่แล้ว

    Halts off for such gr8 explanation, especially those refrences of objects 🙏

  • @sachinchinnannavar9514
    @sachinchinnannavar9514 5 ปีที่แล้ว +1

    it was very good explaination thank you navin.

  • @VedicGemstoneTherapy1027
    @VedicGemstoneTherapy1027 4 ปีที่แล้ว

    But sir I have a question that when the anonymous object/instance calls the show method ,will the object immediately be collected by GC or when the method will have completed its work then the object will be collected by GC.
    *GC - Garbage Collection

  • @ravimaurya2533
    @ravimaurya2533 7 ปีที่แล้ว +6

    you explain so nicely...anybody can understand:)

  • @huidrompunendrajitsingh1758
    @huidrompunendrajitsingh1758 3 ปีที่แล้ว

    wow Sir Navin this topic is very interesting and thanks for sharing these valuable lessons

  • @VedicGemstoneTherapy1027
    @VedicGemstoneTherapy1027 4 ปีที่แล้ว

    It will be 0.since when a new anonymous instance is getting created it will have completely different properties than the previous one.Also instance variables with no values intialized is equal to zero

  • @VivekKumar-ky6tm
    @VivekKumar-ky6tm 7 ปีที่แล้ว

    Thanks sir this beautiful video you such a awesome, you always to take a required time make concept easy to understand,unlike other people who seem in hurry .They often skip some important concept to make their videos short.

  • @yashinsha
    @yashinsha 8 ปีที่แล้ว

    I have a small doubt about stack and heap memory.
    What does these nemofy store?
    Is stack menmory is used to store variables?
    is hdap memory is used to store objects?

  • @noorulhuq5712
    @noorulhuq5712 4 ปีที่แล้ว

    Perfect explanation for this concept....... 👍

  • @NeerajBhasin28
    @NeerajBhasin28 7 ปีที่แล้ว

    hii there, as we create a anonymous object is will occupy the space in heap memory twice....once a null value and second as a value that we have assigned to it....must reply.

  • @rafiulislam1260
    @rafiulislam1260 5 ปีที่แล้ว +1

    wonderful explanation ! you're the best .you are doing a great job sir .

  • @jayeshdharpure5857
    @jayeshdharpure5857 7 ปีที่แล้ว +5

    new A().show();
    It will print 0,because when we call new A() it will create a different new object with initial value of k=0.

    • @vijayvijart8147
      @vijayvijart8147 5 ปีที่แล้ว

      But you do not have variable 'K' inside the new instance. Then how it will allocate K=0. There is no variables ryt ?

    • @nishantchatterjee3049
      @nishantchatterjee3049 4 ปีที่แล้ว +1

      @@vijayvijart8147 When an object is created, all the variables are filled with something called electronic zeroes. All objects become null, ints become 0, booleans become false, etc..

    • @vijayvijart8147
      @vijayvijart8147 4 ปีที่แล้ว

      @@nishantchatterjee3049 tq brother ☺️ better clarification.

    • @vijayvijart8147
      @vijayvijart8147 4 ปีที่แล้ว

      I am not see the variable k which is inside the class. That's y I replied like that.😐

  • @deepaksindhwani7037
    @deepaksindhwani7037 7 ปีที่แล้ว +1

    whenever the new keyword will be used there will be new object will be formed in heap . and initially all instance variable is having 0 values. so my guess is it will print 0

  • @rishabhupadhyay7569
    @rishabhupadhyay7569 8 ปีที่แล้ว

    default value of int k (i.e. = 0). anonymous object can be used once so i think as soon as it is called it is executed and GC dumps it to garbage. now when we call show. it has default value of k.

  • @husainahmed4792
    @husainahmed4792 2 ปีที่แล้ว

    We can declare the variable int K to "public static int k ; " then we can use "new A().K=value;" again and again without losing it's value.

  • @shubhamd417
    @shubhamd417 6 ปีที่แล้ว

    Suppose if i declare a variable k inside a method called as show() and assign the value to k=29 using anonymous object then what will be the output?

  • @mollasakil694
    @mollasakil694 2 ปีที่แล้ว

    It will print zero,bez of instance variables initial value is zero....When we assign value with new A().k =29; then it create a object, secondly when we call show method with new A().Show(); it will create new object.... And new object instance variable value will always be zero...

  • @sufyanali7686
    @sufyanali7686 7 ปีที่แล้ว

    Fabulous explaining sir....

  • @rryann088
    @rryann088 6 หลายเดือนก่อน

    learned something new today! Thanks!

  • @allankumar7552
    @allankumar7552 6 ปีที่แล้ว +1

    before explaining this i will tell you that int k; by default become 0. Than next step go to method in method also print 0.after you display new A().show() call the output will be Zero(0).

  • @adnanjr
    @adnanjr 8 ปีที่แล้ว

    i understand everything you teach.But please will you make a video for showing the distinguish between stack memory and heap memory.literally i don't understand these two concpt

  • @ektakumari3082
    @ektakumari3082 4 ปีที่แล้ว

    The answer would be 26,since as we move to the line having.the line containing the code-new A().k=29, becomes eligible for garbage collection.
    Hence the value would be 26.

  • @giorgi23
    @giorgi23 3 ปีที่แล้ว

    Really valuable content

  • @fozlerabbishafi6036
    @fozlerabbishafi6036 7 ปีที่แล้ว

    Clear explanation sir. Thanks a lot.

  • @karanrawat1659
    @karanrawat1659 4 ปีที่แล้ว

    Soo if we removed new keyword from new A().show() , then it will show the valye 29 na?

  • @hardikhingu8428
    @hardikhingu8428 4 ปีที่แล้ว

    Zero is answer bcz when we write new A().show then it wil create new blcok in heap memory in which the value of k is zero

  • @suchimaheshwari1574
    @suchimaheshwari1574 4 ปีที่แล้ว

    great explanation...

  • @mohammadhaque1873
    @mohammadhaque1873 7 ปีที่แล้ว

    Great. Very good explanation. Thank you.

  • @arunprasadhsj
    @arunprasadhsj 4 ปีที่แล้ว

    you always have best explanation for everything, thank you bro

  • @rohitnegi5197
    @rohitnegi5197 5 ปีที่แล้ว

    Great explanation reddy sir
    .. thanks

  • @BISWAJITSAHUshe
    @BISWAJITSAHUshe 7 ปีที่แล้ว

    Very nicely explained.thank you.

  • @nikunjaggarwal3928
    @nikunjaggarwal3928 6 ปีที่แล้ว

    0 as each time we use the anonymous object it will create a new heap memory so each time we call a data member or method of class a new memory will be in use

  • @shyamkachhadiya4964
    @shyamkachhadiya4964 6 ปีที่แล้ว +1

    sir i have a question, what will be happened the heap memory, as soon the job of anonymous object over, are they deleted from the memory

    • @jennagentles1836
      @jennagentles1836 6 ปีที่แล้ว

      They won't necessarily be deleted right away but they will be eligible for deletion when garbage collection happens. The Java Virtual Machine handles memory management automatically and uses garbage collection to free space by getting rid of objects that are no longer being used.

    • @rajatsharma7596
      @rajatsharma7596 6 ปีที่แล้ว

      Jenna Gentles and the GC always runs !! so they immidiately goes to garbage collection !

  • @aula3153
    @aula3153 7 ปีที่แล้ว

    Thank u very much navin sire u r explained in perfect way

  • @userawqd
    @userawqd 5 ปีที่แล้ว

    Really good explanation!

  • @sureshchan7285
    @sureshchan7285 8 ปีที่แล้ว

    k=0....because heap it create new reference(102) i have question.....your change the value for new A().k=29;..........i want to show k=29....how?

  • @nilesh3659
    @nilesh3659 7 ปีที่แล้ว

    awesome explaination sir

  • @rajraj601
    @rajraj601 5 ปีที่แล้ว

    Awesome teacher !

  • @saloneerege2006
    @saloneerege2006 5 ปีที่แล้ว +2

    Answer for new A().k =29; new A().show() would be 0

  • @youyogesh85
    @youyogesh85 3 ปีที่แล้ว

    Anonymous objects would be good for utilities classes where one just has to use the methods or fetch values from db.

  • @lenimentus4698
    @lenimentus4698 8 ปีที่แล้ว

    The best of the best. I even disable adblocker for you ! Can you start web application development of java or HTML/CSS courses? Thanks a lot, greetings from Germany

  • @MuhammadAmir-mf9xt
    @MuhammadAmir-mf9xt 8 ปีที่แล้ว

    nice excellent explanation thanks to you sir..

  • @radiantthebotgameplay8182
    @radiantthebotgameplay8182 7 ปีที่แล้ว

    every object contain own copy of instance variable so it will give out put as zero
    in case if variable is static then it will give out put as 29...i hope i m right

  • @parthdalvi5855
    @parthdalvi5855 8 ปีที่แล้ว

    Nice, Simple and Clear explanation !! Thank you !! :-) :-)

  • @dreams9322
    @dreams9322 2 ปีที่แล้ว

    Well explained

  • @parthapaul5241
    @parthapaul5241 7 ปีที่แล้ว

    explanation is lovely

  • @pankajchopra2638
    @pankajchopra2638 6 ปีที่แล้ว

    how will we print 29 by using anonymous object? and if we cant do this then alternatevly we have to use referenced object?

    • @rajatsharma7596
      @rajatsharma7596 6 ปีที่แล้ว

      pankaj chopra the main purpose is to use or call the method of the class if you need to call them only once ! otherwise go for reference variable

  • @rajatsharma7596
    @rajatsharma7596 8 ปีที่แล้ว

    woww,,,hats--off sir!! the great explaination ever!! :)

  • @SurajKumar-ym1cr
    @SurajKumar-ym1cr 5 ปีที่แล้ว

    Answer will be zero or garbage value of k as new A() will create another object in heap

  • @neerajkumarsharma5123
    @neerajkumarsharma5123 6 ปีที่แล้ว

    Excellent explanation sir .... Ise kehte hai hip hop hip hop

  • @AkhilKumar
    @AkhilKumar 8 ปีที่แล้ว

    Nice and clear. Thank you! Please upload videos to Udemy :)

  • @apiautomationtester2567
    @apiautomationtester2567 7 ปีที่แล้ว

    super, please post video on code coverage tools like ecl emma which is used in eclipse

  • @mohammedbasith6781
    @mohammedbasith6781 4 ปีที่แล้ว

    the answer is '0' because it is creating each time a new anonymous obj.

  • @happylife5731
    @happylife5731 8 ปีที่แล้ว

    is calling of anonymous class is possible?

  • @neeharikaadella6126
    @neeharikaadella6126 4 ปีที่แล้ว

    Thank you very much sir

  • @lenimentus4698
    @lenimentus4698 8 ปีที่แล้ว

    Very good!

  • @saicharan5596
    @saicharan5596 8 ปีที่แล้ว

    Excellent ,Thank u so much ....

  • @parasarora2606
    @parasarora2606 8 ปีที่แล้ว

    sir if we use obj.close(); instead of anonymous object

  • @manikandan2890
    @manikandan2890 3 ปีที่แล้ว

    the answer is 0 .becoz whenever u use new A()it will create a new object inside the heap memory. so the k value will be 0

  • @RahulKumar-de2rw
    @RahulKumar-de2rw 5 ปีที่แล้ว

    Good one

  • @sriramkumar5303
    @sriramkumar5303 5 ปีที่แล้ว

    All i can see is the brightness of the whiter board is continuously changing some kind of morse code.

  • @AbhiTadwalkar
    @AbhiTadwalkar 5 ปีที่แล้ว

    The answer is reference value of new A() created in heap memory

  • @mohammedalmahfoodh1
    @mohammedalmahfoodh1 6 ปีที่แล้ว

    The answer is k=0 since it's new objekt not the same one you have created and gave it 29

  • @haimai1595
    @haimai1595 6 ปีที่แล้ว

    Thank you

  • @pawemackowski1493
    @pawemackowski1493 3 ปีที่แล้ว

    thank you for the video

  • @mihirvaghela3479
    @mihirvaghela3479 4 ปีที่แล้ว

    good one

  • @premkumar-jz4di
    @premkumar-jz4di 2 ปีที่แล้ว

    Super sir

  • @tulaveerababu7564
    @tulaveerababu7564 7 ปีที่แล้ว

    using static keyword (static int k) to get the o/p as 26

  • @AhmedElsayed-ur1iy
    @AhmedElsayed-ur1iy 5 ปีที่แล้ว

    dude ur the best

  • @VivekKumar-ky6tm
    @VivekKumar-ky6tm 7 ปีที่แล้ว

    value of k would be 0, because anonYmous object will again create new copy of class in heap section of memory.With new variables ,i guess

  • @leelakarreddyvaranasi2521
    @leelakarreddyvaranasi2521 7 ปีที่แล้ว

    new A().show() displays 0,becoz new keyword creates another new object reference in heap memory

  • @barath9815
    @barath9815 7 ปีที่แล้ว

    can i pass parameter in it sir???? like this new A().show(5);

  • @lavishjain6305
    @lavishjain6305 7 ปีที่แล้ว

    answer would be 0 ....
    as new a().show() will create another object in heap memory and value of k here is its default value =0....

  • @maitrishah820
    @maitrishah820 4 ปีที่แล้ว

    ans is 0 because the new A().show(); is create new properties in heap memory, and the first new a=29 is go in to garbage collection. :) i hope this ans is write..

  • @clintothomas397
    @clintothomas397 7 ปีที่แล้ว

    both the new A() objects are different as long as there is no reference .

  • @YOGESHSHARMA-yy8ns
    @YOGESHSHARMA-yy8ns 8 ปีที่แล้ว

    0 since there's actually no reference their, the second statement will create a new anonymous object.

  • @ramyapriyadarshini7510
    @ramyapriyadarshini7510 4 ปีที่แล้ว

    Just make show a static function. If you're gonna call it only once you're probably not gonna have a local variable.

  • @nebilgokdemir4527
    @nebilgokdemir4527 5 ปีที่แล้ว

    it is going to be 0 value, By ways it is great tutorial i love it, thanks for sharing

  • @ericevansochil2875
    @ericevansochil2875 6 ปีที่แล้ว

    thanks very much

  • @trendingvideos2517
    @trendingvideos2517 7 ปีที่แล้ว

    it will not print 29 when we call show.