8.15 Anonymous Object in Java

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 ม.ค. 2025

ความคิดเห็น • 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 ปีที่แล้ว +7

    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.

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

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

  • @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

  • @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.

  • @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 !

  • @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 👍🏻❤️

  • @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..!!!

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

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

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

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

  • @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.

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

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

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

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

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

    None has ever explained to me so beautifully before.

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

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

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

    it was very good explaination thank you navin.

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

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

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

    Wonderfully explained each and every point.

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

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

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

    our are such a real boss of programming

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

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

  • @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

  • @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.

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

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

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

    you always have best explanation for everything, thank you bro

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

    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

  • @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?

  • @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?

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

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

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

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

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

    Great. Very good explanation. Thank you.

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

    learned something new today! Thanks!

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

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

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

    Great explanation reddy sir
    .. thanks

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

    Clear explanation sir. Thanks a lot.

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

    Fabulous explaining sir....

  • @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

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

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

  • @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 !

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

    Really valuable content

  • @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

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

    Very nicely explained.thank you.

  • @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.

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

    Really good explanation!

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

    nice excellent explanation thanks to you sir..

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

    great explanation...

  • @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

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

    awesome explaination sir

  • @jayeshdharpure5857
    @jayeshdharpure5857 8 ปีที่แล้ว +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.😐

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

    Awesome teacher !

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

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

  • @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

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

    what if the variable k is static in that case will the show still print 0 or 29 ?? if anyone could clarify
    thanks :)

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

      29 in that case.

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

    Well explained

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

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

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

    explanation is lovely

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

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

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

    Excellent ,Thank u so much ....

  • @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

  • @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?

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

    Very good!

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

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

  • @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

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

    Thank you very much sir

  • @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...

  • @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).

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

    Good one

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

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

  • @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.

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

    it will not print 29 when we call show.

  • @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.

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

    is calling of anonymous class is possible?

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

    thank you for the video

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

    good one

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

    lets say i have a class Avatar...Avatar obj1= new Avatar();
    obj1.a=23;
    obj1.show();..I will get 23..
    now..new Avatar().a=56;
    new Avatar().show();..this will give 0..then what is the main reason why we are using this anonymous..plz expalin someone...

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

    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

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

    Super sir

  • @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

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

    dude ur the best

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

    Thank you

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

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

  • @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

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

    we get zero from, method show()... if we use anonymous Object

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

    can we do something like: A obj = new A().i=29;
    i know its stupid!

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

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

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

    After asigning the valute to K That will be eligible for GC so it wont be able to call Show

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

    thanks very much

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

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

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

    if we write static int k then it will print 29

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

      HARSHITHA J nops !! then still you have to initialise at the class memory ! and if you want to initialise at class level then even non static int k also print 29 !! no issue .

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

    make sense thank you

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

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

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

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

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

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

  • @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

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

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