Top 10 Static & Instance Block Based Interview Questions || Tricky Java Interview Questions

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

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

  • @sridharlanka2721
    @sridharlanka2721 3 года назад +32

    Give this man a medal🥇

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

      a trick : watch series on flixzone. I've been using it for watching a lot of movies during the lockdown.

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

      @Jon Russell yea, have been watching on flixzone} for since december myself :)

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

    These are the most common nd Basic part of java
    But people are confusing about it. Nd u explained it very Simply way. Thanks Naveen 😊

  • @ShinAkuma
    @ShinAkuma 3 года назад +7

    15:00 It's because of the "final" keyword.
    If X was only static and not final, the static block would be called.
    Explaination in a layman's terms would be, if a variable is static and final, it means that it's shared between all objects and it's value cannot change, hence the compiler will simply put it's value in the calling statement instead of referencing it from the original class.
    If it was not final, means the value of x is changeable, therefore directly putting the value in the calling statement could cause inconsistencies.

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

      @Coder Toaster - many thanks 👍

  • @nikeshkumar-gl1fv
    @nikeshkumar-gl1fv 3 года назад +3

    One of my favourite teacher, who used to give concepts from scratch . 🙏🙏

    • @nikeshkumar-gl1fv
      @nikeshkumar-gl1fv 3 года назад +1

      Sir currently I got placed in COGNIZANT and my job role is SDET , initially they are giving internship where they are teaching java,SQL, spring framework, spring MVC, spring boot, selenium, HTML,css, Restful api, microservices and many more . And your tutorial is purely based on Sdet role . Thanks sir 🙏🙏🙏🙏🙏🙏🙏

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

    no more confusion on static block....thank u myguru....!!!!

  • @niloybasu6508
    @niloybasu6508 Год назад +1

    This is really very useful..Completely cleared my doubts. Thanks a lot for making such awesome videos.

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

    Perfect series for interview preparation...👌

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

    11:49- the question is run program without writing main method but you executed program inside the main method by creating object.

  • @m.smanoj4688
    @m.smanoj4688 3 года назад +2

    Awesome questions my friend 🤗.even in clg they won't teach this hidden techniques

  • @SumitSharma-qq4hk
    @SumitSharma-qq4hk 3 года назад +3

    Awesome.... Everytime there is a video by you, I learn something new

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

    I have a very simple question.
    But before asking that I must appreciate the way you explained these super-10 questions.... Absolutely heavenly ...
    coming to my question,
    Sir may you please tell me the practical application of the static block and the instance Inisialisation block in a real world situation. An example describing both of these applications would help me a lot.

  • @munich-germanylife8207
    @munich-germanylife8207 3 года назад +1

    Overall explanation was good but I didn't find the answer for below things :
    1. If Constructor is Private and I am writting a object creation in static block how I can use it outside class
    2. Can I run the code witout Main() method, of yes I think you could have given one example in one class without main method instead of calling a second class where main method is not there
    But again sir big fan , always love your content.Please keep on doing your good works and help others to upskill there knowledge

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

    Naveen I can't thank you enough👍
    Keep creating more and more
    your daily videos motivates me to learn further more
    Naveen ,one more thing recently I came through a string question and I tried to do it on my own
    but Expected output is not coming I'll paste question here do give me a solution Naveen if you Know
    QUESTION :
    " Welcome to Java and Python "
    Replace first 2 letters of each word in given string with number 12
    EXPECTED OUTPUT:
    " 1212lcome 1212 1212va 1212d 1212thon "

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

      Just use Stringtokenizer.. Tokenize the string with default constructor and u will get each words thn change the first two characters to 12

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

    Thanks Naveen..Its really helpfull for interview preparation.

  • @vibhanidhi
    @vibhanidhi 3 года назад +4

    Thanks Naveen..👍👍it's really helpful..pls continue such type of interview questions series

  • @pandudamera7211
    @pandudamera7211 3 года назад +4

    Great collection brother

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

    🔥🔥🔥🔥
    Thank you sir...
    Stay safe and keep making these type of videos....

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

    Thanks a lot Naveen for preparing this series.. You are superb

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

    Amazing explanations sir, I am really fortunate to find such great content in RUclips.

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

    Hi Naveen, i am curious to understand where exactly a static block can be used in a framework design and how it will serve the purpose. Also a request when you explain the concept please explain where exactly it will fit in framework. It will help us to create better framework.

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

    Really great work sir,..ameerpet,Hyderabad mein venkatesh sir bolke ek sir hai..yeh poora bolthe thei,as per the interview's going on..aap unki yaad dilaadi hai..thank u :):)

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

      Thanks brother. I have never been to Ameerpet, Hyderabad. Wish one day I'll visit that place.

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

      @@naveenautomationlabs always welcome sir..god bless u :)

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

    VERY HELPFUL THANK YOU SIR

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

    You are a perfect teacher great work!

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

    Okay this is the first time I heard of such things..

  • @m.smanoj4688
    @m.smanoj4688 3 года назад +2

    Pls continue this type of interview questions

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

    Great video Naveen 👍👍👍

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

    Awesome explanation! these could be quite tricky even for some experienced programmers.

  • @015kavya
    @015kavya 3 года назад +1

    Thank you so much Naveen. It looks easy but its very tricky

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

    Hi Naveen, Thanks for such helpful videos. I have started my career as a manual tester n now moved to automation by watching your videos.
    One question: how to take a screenshot of full page is one go(e.g there is one page where we need to scroll, wo how to take single screenshot of that page)?

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

    In general also we execute programs by not creating any object(in the code)
    we write
    class{
    public static void main(){
    }
    }...
    it will work without creating any object right

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

    Very useful content...great Naveen!!

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

    Very helpful..plz continue with such videos

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

    Thank you sir for such amazing explanation 🙏

  • @padminib.v.8509
    @padminib.v.8509 3 года назад +1

    Thank you very much Naveen sir for these series.. Really helping a lot 😊

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

    Nice explaination ,, Thanks 👍👍

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

    Thanks Naveen.Great initiative. Keep going.❤️❤️

  • @k.ravichandra1049
    @k.ravichandra1049 2 года назад

    Thanks a ton NAVEEN for covering Static and Instance related questions which are very useful. Keep up the Good 👍 work. Also in video Q5 is without using main() method but explained using main() method pls check once.or did I miss anything pls clarify

  • @ahamedabdulrahman
    @ahamedabdulrahman 3 года назад +7

    Naveen, a great series. One doubt. In question 4, the question is to run a Java program without main() method. You have created a class without main method but called that class from another main method only, isn't it?

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

      After watching the video, the same question came to my mind right away. so, I tried to check the comments to find the answer but still couldn't if you have the answer or Naveen knows the answer please kindly share it

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

    Love your work. Keep making videos❤️

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

    The java compiler copies the instance initializer block in the constructor after the first statement super(). So firstly, constructor is invoked.

  • @-Shivaprasad-qg5qj
    @-Shivaprasad-qg5qj 2 года назад

    You are awesome.... Sir

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

    nice explanation Naveenji ,but I have a doubt though we are creating object in static method, still we are using same private constructor, so logically it should not create object ri8? ..is it like we are creating object in somewhere other than heap memory?. Expecting your reply. Thank you!

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

    Naveen just one question if we can create instance for class which has private constructor inside static block/method then how can we achieve singleTon class or Object ? as SingleTon Object was meant for not to allow to create more than one instance by making constructor as private ?

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

    I am regularly follow your videos. It's awesome explanation. I have a doubt, in this video at 11.01, you are still using main method. Please explain this.

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

    Very helpful video. Thank you so much 🙏🏻

  • @Anastasia-bo1uc
    @Anastasia-bo1uc 3 года назад +1

    Thank you! Great explanation! ❤

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

    It's very helpful thank you :)

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

    Hi Naveen sir , you created object of static block class in main method. #regarding complile n run without main method questions. Only one main method is needed in java project. Could you please clear my doubt

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

    Thank you so much..

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

    at 16:50>> answer will be static block and main, because object is not created so instance block will not be executed.

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

    please give any real time scenario where we can use it in our script .

  • @VineetKumar-eb3lv
    @VineetKumar-eb3lv 3 года назад +1

    Thank you Naveen

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

    Thank u guru

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

    Hello, I have a quick doubt: Technically, aren't we creating String objects and interning them (because we used literals) in the second question? I understand, you not calling any of the classes you defined before but String are created, right? Thanks for the video.

  • @nitzcookinglove2477
    @nitzcookinglove2477 3 года назад +4

    Very helpful

  • @8073-z6w
    @8073-z6w Год назад

    Amazing 🤩

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

    How to access the object created in static block in another class?

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

    This is great

  • @vikasyadav-es8uh
    @vikasyadav-es8uh 3 года назад +1

    Output will be :-
    First static block will execute at the time of class loading then main method execute
    :- static block
    :- main method
    Non static block will not execute becouse at the time of object creation constructor will be called and befor executing constructor non static block will execute so in this case we are not creating object so no instance block no constructor..... M i right

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

    Nice one. Please create similar complex type interview questions on collection framework.

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

    Naveen sir, how can we utilize the obj created in the static block , in another class?

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

    In question 6 how can an instance variable can access in static block whereas static block accepts only static variables or method, Can u explain brother..?

  • @alaaali9745
    @alaaali9745 3 года назад +3

    naveen can u discuss testing mobile interview question and especially Appium automation

    • @naveenautomationlabs
      @naveenautomationlabs  3 года назад +4

      Sure I'll prepare one series on appium Interview questions

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

      I have interview next Tuesday, i hope that u can send me some questions so i can prepare

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

    Thanks @Naveen sir for this series

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

    For Q.8 in the output questions in the second part of video, if I remove the final keyword from variable, even if the static keyword is present the static block is getting executed. Why is that? including the final keyword does not loads the class?

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

    u nailed it 🔥

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

    Nice video,Please share interview questions on multithreading

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

    one doubt in the time interval 11:51 and 14:24 same kind of code is present for static variable and blocks then how the static block in 11:51 alone execute?

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

    If we are creating an object of the class in the static block , how do we access it from another class?

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

    Hi sir,
    Why non static block execute before constructor?

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

    sir in q5 we cant do anything in java if main method is not written...........

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

    is the relationship between Java and HTML, CSS, python, XML please show me a program that is made with all these?

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

      its a wrong question. You are comparing orange with apple here. You dont write java code with python. Also what does it mean relationship between java, python, xml, css and html?

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

    what's the package Java practices doing in that programs

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

      why? how does it matter? its a package name where class is present.

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

    4th question is Singleton class?

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

    Bhagwan aapko ek din Tesla ka CEO banaye .jinke sirf tweet karne se shares ke price badh jaate hai .

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

    Hey Naveen can we call static method inside static block???

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

      Yes, you can.
      static {
      System.out.println("hi");
      test();
      }
      public static void test() {
      }

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

      One more confusion I have......
      Can we call non static mathod in static block.....
      I tried to refer some site but it is showing results for .... I can't call non static method in static method......
      But my question is can we call non static method in static block..

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

    Hey Naveen, In Q10 You said Constructor of the class will not be called if you will not create the object of the class @17:18
    In your POM Framework video [(ruclips.net/video/LxJzeiTQGoE/видео.html); @58:40]. You created a LoginPageTest Constructor to call parent class constructor so that config.properties file can be loaded.
    Now My Question is We have not created any object of LoginPageTest but still constructor of LoginPageTest is called, why ?
    If you try this inside psvm(String[] args) then the constructor will not be called, But in TestNG Constructor is being called even without creating Object. Can you or anyone explain this.

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

    Please provide your telegram link updated

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

    Disliking this video is a crime.

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

    About Question 2 , Isn't "System" an object ?

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

      System is a class in Java, not an Object.

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

      @@naveenautomationlabs ah i see, I'm learning java and your videos are a huge help, thank you for the reply.

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

    please subtitle