Immutable Class - interview insights| java interview questions and answers for experienced/Freshers

Поделиться
HTML-код
  • Опубликовано: 6 окт 2024

Комментарии • 92

  • @petitexplorer23
    @petitexplorer23 3 года назад +34

    Hey Abhilash! The day I watched this video just after receiving your channel update, the very next day I had my interview and guess what the interviewer asked me this particular question and he had given me the exact same example (every bit was similar) and I also gave him the same explanation and guess what I cleared that round. The moment I heard this question I was like thank you , thank you Abhilash for this video, it saved one of my opportunities. You are fab man! Thanks a ton :) Keep teaching, I will keep learning :) Bless you

  • @ayushsaxena3511
    @ayushsaxena3511 3 года назад +6

    Just randomly watched this video and ended up liking and subscribing the channel.
    It's so good to see that you guys are contributing so much in training and educating the developer's community.

  • @udaypandey5659
    @udaypandey5659 2 года назад +1

    Lovely explanation! But still there is a catch which can break this I think : in student constructor you are directly assigning adress ex : this.address = address;
    It's should be something like this.addres = new Address ( adress.city , adress.state, adress.country) .
    Because when you created adress in main method , you still know that refrence . So alway clone before assigning in constructor

  • @mridulupadhyay5058
    @mridulupadhyay5058 3 года назад +5

    You are doing awesome Job, I have literally cracked interviews of many companies by watching your Spring concepts, thanks so much for your valuabe teaching,also please if possible create video for microservices with spring boot also.

  • @ratansarkar7444
    @ratansarkar7444 8 месяцев назад

    Your video defines how much effort you have puted when you have learnt this concepts

  • @anjanakarthiktangirala2430
    @anjanakarthiktangirala2430 3 года назад

    Clean... Clear... Crisp.... This is one of the best explanation i ever heard. Kudos to you all.

  • @vakkalahari5449
    @vakkalahari5449 2 года назад

    Your teaching like feed with spoon for students, The best lecturer in RUclips, he must get more subscribers !!!!!!

  • @deepa8177
    @deepa8177 2 года назад +1

    superb, i wasn't aware of so many other possibilities, Thanku so much. definitely it will be very helpful in the interviews & thanks for sharing the real time approach also as it wouldn't be a new thing in future coj of your informative videos. Really each & every aspect is covered.

  • @manidixit6713
    @manidixit6713 3 года назад +2

    I went to your website and saw Spring boot course and it costs 15000 !!!!
    Why man why.. U r the best trainer for me .. Everyone can't offord such high price course. I request u to add your course in udemy with much less cost. ☺🙂

  • @MohitKumar-cq2rj
    @MohitKumar-cq2rj 3 года назад +1

    Sir, I am very helpful and lucky that i am able to learn n understand Java / spring by your uploaded youtube video. I request you to provide spring boot and spring microservice video tutorial in upcoming days asap. please...!

  • @sibinthink7736
    @sibinthink7736 2 года назад

    Abhilash I got selected just watching your tutorials. THANKS A LOT TON CRORE...subscriber 🙏

  • @mukulkopulwar
    @mukulkopulwar 8 месяцев назад

    Clear and Crisp Explanation Abhilash. Thanks for sharing.

  • @wisdomeducation6884
    @wisdomeducation6884 3 года назад

    Brother im completely impressed. I never understand this topic before like that

  • @brijeshpatra1629
    @brijeshpatra1629 Год назад

    Damn man once you start watching his videos there is no go back ♥️

  • @deepa8177
    @deepa8177 7 месяцев назад

    again watching this video literally so great informative video..

  • @aycricoder6395
    @aycricoder6395 3 года назад +1

    Love u bro... u r a motivation an inspiration... the reason i started finding interest in coding

  • @shubhamthakare7694
    @shubhamthakare7694 3 года назад

    One of best video on Immutable class

  • @thangaduraik5364
    @thangaduraik5364 2 года назад

    Big thanks man. Way of teaching is great.

  • @suseesenthil417
    @suseesenthil417 11 месяцев назад

    Could you please upload Java core videos (I am very excited to learn the fundamentals from you. You are covering the in-depth knowledge which on one covered in my knowledge so far..)

  • @ramanandkumar7780
    @ramanandkumar7780 3 года назад +1

    Nicely explained....I have one double ,what is the use of making the class final as already all the data members are final ,no setter method, get method is not returning the original object.

  • @youssefmoussa2523
    @youssefmoussa2523 3 года назад

    Hi Mr Abhilash i miss you soo much. I miss also your videos. You are the best teach in youtube you must know that.

  • @venkatashanmukha348
    @venkatashanmukha348 3 года назад +1

    Happy to see after longdays

  • @Krishwithniece
    @Krishwithniece 2 месяца назад

    Instead of creating clona object for address do convert into immutable of address class then state of data won't change right

  • @nareshKumar-ej7nk
    @nareshKumar-ej7nk 3 года назад

    Increasing confidence on java.. Thank you 😍

  • @amolmehlawat8197
    @amolmehlawat8197 3 года назад

    Great to have you back Sir. Eagerly waiting for the follow-up video. 👍🏼

  • @pandeyjii
    @pandeyjii 3 года назад

    Hi Abhilash Thnaks for this video, that's very great each and exery step explained well, can you please make one video on complete Data JPA

  • @madhuri5371
    @madhuri5371 2 года назад

    very well explained sir.Thank you for this video.

  • @PankajKumar-qk8oh
    @PankajKumar-qk8oh 3 года назад

    Great explanations....really helpful for interview

  • @sameer9368
    @sameer9368 2 года назад +1

    You deserve a beer bro...superb explanation 💪💪

  • @rishibharadwaj68
    @rishibharadwaj68 Год назад

    I have a question, what if the Address object that is being used to pass to the Student class constructor is manipulated. The method, where we are creating the Address object has the reference to it. Now though the student object cannot be used to manipulate Address, but the address reference can still manipulate the Address Object inside the Student Object. I think we should clone the passed Address Object as well and then assign it to the Student address member.

  • @worldofwomen3726
    @worldofwomen3726 Год назад

    Student1 s=new Student1(1, "gayathri");
    System.out.println(s);
    s=new Student1(2,"devi");
    System.out.println(s);
    with this the values we can change right even though the variables are final

  • @santhoshchandran6952
    @santhoshchandran6952 2 года назад

    Abhi, try to add more live interview..it's interesting to watch and helpful that how to present during interview. Nice explanation.

  • @vinaykumar-no2zh
    @vinaykumar-no2zh 2 года назад +1

    Hi Abhilash, In this Student Class constructor, i think we need this.addr = new Address(addr.city,addr.state); this statement instead of directly assigning the reference like this this.addr = addr i hope this is the correct way.correct me if it is wrong.

  • @jagrutipatil1020
    @jagrutipatil1020 Год назад

    Thanks Abhilash ☺️

  • @Srdc-hw5qc
    @Srdc-hw5qc 3 года назад

    Hi sir finally I got job in mnc company after seeing your videos so many thanks to you

  • @ratunawartejas
    @ratunawartejas 2 года назад

    This was really helpful content. Thanks Abhilash

  • @jeevantesting2501
    @jeevantesting2501 3 года назад

    Hi Abhi,
    The point you mentioned during explanation of advantages of Immutable objects - "thread safety is guaranteed because data inconsistency is avoided in a multi-threaded environment".
    How can data inconsistency arise for a immutable object when it cannot be modified in the first place? or did I miss something?

  • @NITISHKUMAR-nx9mk
    @NITISHKUMAR-nx9mk 2 года назад

    Very Nice Explanation!!

  • @rkm7184
    @rkm7184 3 года назад +1

    Appreciate your teaching ways with explanation but if you make it within 10 minutes video not 40, 50 minutes for a small topic. That would be great for learner otherwise will skip

  • @rohitsharma-xt8qe
    @rohitsharma-xt8qe 3 года назад

    Everything is good Abhilash the only thing I wanted to say, some portion of the video is a little exaggerated which is not required, the video could have been a little short.

  • @rajajodhani
    @rajajodhani 2 года назад

    Amazing explaination

  • @PhaniKancharla18
    @PhaniKancharla18 3 года назад

    Hi Abhilash, it's very clear and nice video. I have doubt can we give clone object of addres obj in the get method of student instead copy constructor. As implementing colnable interface in address class

  • @marotikudale2890
    @marotikudale2890 2 года назад

    Very nice quations

  • @rahulpant7795
    @rahulpant7795 3 года назад

    good explanation. thanks.

  • @raceyat
    @raceyat 3 года назад

    Is been a while. Good to here from you.

  • @MostafaTavassoli
    @MostafaTavassoli 2 года назад

    Amazing video, Abhilash.

  • @Phanikishore_adda
    @Phanikishore_adda 3 года назад

    Hi Abhilash
    Can you take concurrency Concepts in Java and make videos?

  • @pratheeban3650
    @pratheeban3650 3 года назад

    Simply awesome

  • @devireddyjayanthreddy839
    @devireddyjayanthreddy839 3 года назад

    hi brother, plz make the video in ......."debugging concepts" .....in java

  • @vishnupriya739
    @vishnupriya739 2 года назад

    super..

  • @digvijay1228
    @digvijay1228 11 месяцев назад

    Hi @Selenium Express,
    is the below code too violation of immutable class. If yes, please help in correcting.
    Address address = new Address("MAA", "Tamil Nadu");
    Student student = new Student("Me", 20, address);
    System.out.println(student);

    address.setCity("BLR");
    address.setState("Karnataka");

    System.out.println(student);

  • @HITENDRAsingh-kh4ho
    @HITENDRAsingh-kh4ho Год назад

    Hey
    in which video have you explained why to declare immutable class as final?
    please link it

  • @aashishpundir3019
    @aashishpundir3019 2 года назад

    but what if we change the content of Address class object using homeAddress object here we are creating separate copy so it works as expected.
    try this example:
    Address homeAddress=new Address("delhi", "Delhi", "India");
    ImmutableClasses ic=new ImmutableClasses(1,"Aashish",homeAddress);
    System.out.println(ic+" "+ic.hashCode());
    homeAddress.setCity("Kotdwar");
    homeAddress.setState("Uttarakhand");
    System.out.println(ic+" "+ic.hashCode());
    Rest everything is fine we can add below lines to the constructor of Immtable class->
    public ImmutableClasses(int id, String name,Address address) {
    this.id = id;
    this.name = name;
    Address clone=new Address(address);
    this.address=clone;
    }
    it will change the content of homeAddress object. @selenium express please correct me if i am wrong.

  • @softwaredevelopmentandtest8058
    @softwaredevelopmentandtest8058 3 года назад

    pls upload the video for spring boot snd microservices

  • @hinayadav6460
    @hinayadav6460 2 года назад

    Quality content 🔥🔥

  • @vaibhavsavner2452
    @vaibhavsavner2452 3 года назад

    can you make a vedio of spring mvc with firebase push notification.

  • @truecompiler
    @truecompiler 4 месяца назад

    💫

  • @yoshitamahajan353
    @yoshitamahajan353 3 года назад

    Thank u so much!

  • @SriHariChukka1210
    @SriHariChukka1210 2 года назад

    Great stuff 🙂

  • @nguyenquan4836
    @nguyenquan4836 Год назад

    ❤❤❤

  • @shasha6538
    @shasha6538 2 года назад

    I think one scenario is missing. If I have list object, how will you deal with that? This scenario should be covered.

  • @hackstreet781
    @hackstreet781 3 года назад

    Good stuff

  • @danijelmacej7483
    @danijelmacej7483 3 года назад

    Abilas we waiting for spring boot course over 1 year, and now we must to pay. That course is most important to us for job.

    • @nicolucian6604
      @nicolucian6604 3 года назад

      A tip: you can watch series on flixzone. I've been using them for watching lots of of movies lately.

    • @ahmedizaiah9199
      @ahmedizaiah9199 3 года назад

      @Nico Lucian Yup, been watching on Flixzone for since november myself :D

  • @parmodprajapati
    @parmodprajapati 2 года назад

    Hi
    I have one query:
    Can we create a duplicate object of the immutable class using serializable or reflection API?

  • @pavankrishnab1
    @pavankrishnab1 2 года назад +1

    You missed FINAL keyword before class consequences

  • @youssefmoussa2523
    @youssefmoussa2523 3 года назад

    Please give me a favor i need to learn spring boot can you post some videos about it. Sorry for my English

    • @ParmanandKumar-fj9ct
      @ParmanandKumar-fj9ct 3 года назад

      So you will be creating new object for each get method. Is this a correct approach

  • @rkm7184
    @rkm7184 3 года назад +1

    Your example has 1 bug. If you do any changes in homeAdress object then it will break immutable class concept. Don't take it otherwise. I have been learning very good concepts from your videos

    • @gundamaiahannamaina9273
      @gundamaiahannamaina9273 3 года назад

      Yes. To fix this, you need to change the student constructor

    • @gundamaiahannamaina9273
      @gundamaiahannamaina9273 3 года назад

      I used cloning for address object

    • @gundamaiahannamaina9273
      @gundamaiahannamaina9273 3 года назад

      In Address class, implement Clonable and add clone method. @Override protected Address clone(){return new Address(this.city,this.state,this.country); }

    • @gundamaiahannamaina9273
      @gundamaiahannamaina9273 3 года назад

      And in Student constructor
      public Student(int id, String name, Address address) {this.id = id; this.name = name; this.address = address.clone(); }

  • @venkatashanmukha348
    @venkatashanmukha348 3 года назад

    Waiting for spring boot microservices video

  • @RamKumar-rg3gr
    @RamKumar-rg3gr 3 года назад

    Is that penny from big bang theory

  • @mils3318
    @mils3318 Год назад

    Isn't this kind of copying things called "defensive programming"?! Correct me if i'm wrong

  • @anshupanda2149
    @anshupanda2149 3 года назад

    When is the next session??

  • @neerajchavan9760
    @neerajchavan9760 3 года назад

    Hey Abhilash! You really have put on some weight.😂

  • @busyday2023
    @busyday2023 2 года назад +1

    Why are u repeating the same thing too many times and wasting our time. It's a 10 min video. Bro Better don't do videos seriously frustrating and wasting time by repeating

  • @himanshutiwari6579
    @himanshutiwari6579 2 года назад +1

    pahle toh apna pronunciation correct karo...Please dont try to sound like foreigner .Be you ,be original

    • @SeleniumExpress
      @SeleniumExpress  2 года назад

      Hi Himanshu ! Thank you for taking time and writing a feedback.🙂

  • @maan9011
    @maan9011 3 года назад

    You put on weight u were good when u was lean🤣
    Your knowledge directly proportional to weight

  • @sarthakjain6075
    @sarthakjain6075 2 года назад

    Boss sorry but your videos are too lengthy, really difficult to watch such a long video for small topics..

  • @muralitekumatla4699
    @muralitekumatla4699 2 года назад

    Hi Abhilash,
    Very impressive explanation :)
    But I have a doubt - Immutability means " Once an object is initialized, we are not allowed to change its content(value). And when we try to change its content, if there is any change in the content then new object will be created, if there is no change in the content then the original object should be returned" . Just given String behavior example below....
    package com.corejava.string;
    public class StringTest {
    public static void main(String[] args) {

    String str1 = new String("Murali");
    String str2 = new String("Murali");
    String str3 = new String("Murali Tekumatla");
    String str4 = str1.replace('M', 'M');
    String str5 = str1.replace('M', 'T');

    System.out.println("str1 ======" + str1 + "=======" + str1.hashCode());
    System.out.println("str2 ======" + str2 + "=======" + str2.hashCode());
    System.out.println("str3 ======" + str3 + "=======" + str3.hashCode());
    System.out.println("str4 ======" + str4 + "=======" + str4.hashCode());
    System.out.println("str5 ======" + str5 + "=======" + str5.hashCode());
    System.out.println("str1 ======" + str1 + "=======" + str1.hashCode());

    }
    }
    Output:
    str1 ======Murali=======-1978977868
    str2 ======Murali=======-1978977868
    str3 ======Murali Tekumatla=======1155040398
    str4 ======Murali=======-1978977868
    str5 ======Turali=======-1778573811
    str1 ======Murali=======-1978977868
    1. In above example, str1 created.
    2. str2 object created with same content hence it return original object as hashcode is same as str1.
    3. str3 created with differenct content hence new obj is created with diff hashcode.
    4. str4 - trying replace char 'M' with 'M', no content change hence original obj is returned.
    5. str5 - trying replace char 'M' with 'T', content change is there hence new obj is created.
    I think we are missing this behavior in our Student-Address example in this video - can you please comment on this.
    - Thanks