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.
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 🙏🙏🙏🙏🙏🙏🙏
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.
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
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 "
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.
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 :):)
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)?
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
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
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?
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
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!
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 ?
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.
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
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.
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
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..?
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?
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?
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?
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..
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.
Give this man a medal🥇
a trick : watch series on flixzone. I've been using it for watching a lot of movies during the lockdown.
@Jon Russell yea, have been watching on flixzone} for since december myself :)
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 😊
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.
@Coder Toaster - many thanks 👍
One of my favourite teacher, who used to give concepts from scratch . 🙏🙏
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 🙏🙏🙏🙏🙏🙏🙏
no more confusion on static block....thank u myguru....!!!!
Most welcome :)
This is really very useful..Completely cleared my doubts. Thanks a lot for making such awesome videos.
Perfect series for interview preparation...👌
Thank you 😊
11:49- the question is run program without writing main method but you executed program inside the main method by creating object.
Awesome questions my friend 🤗.even in clg they won't teach this hidden techniques
Awesome.... Everytime there is a video by you, I learn something new
Glad that you are learning from my channel 😊
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.
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
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 "
Just use Stringtokenizer.. Tokenize the string with default constructor and u will get each words thn change the first two characters to 12
Thanks Naveen..Its really helpfull for interview preparation.
Thanks Naveen..👍👍it's really helpful..pls continue such type of interview questions series
Thanks for watching :)
Great collection brother
🔥🔥🔥🔥
Thank you sir...
Stay safe and keep making these type of videos....
Thank you harsh.
Thanks a lot Naveen for preparing this series.. You are superb
It's my pleasure
Amazing explanations sir, I am really fortunate to find such great content in RUclips.
Glad to hear that
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.
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 :):)
Thanks brother. I have never been to Ameerpet, Hyderabad. Wish one day I'll visit that place.
@@naveenautomationlabs always welcome sir..god bless u :)
VERY HELPFUL THANK YOU SIR
You are a perfect teacher great work!
Okay this is the first time I heard of such things..
Pls continue this type of interview questions
Great video Naveen 👍👍👍
Awesome explanation! these could be quite tricky even for some experienced programmers.
Thank you so much Naveen. It looks easy but its very tricky
Glad that you got it.
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)?
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
Very useful content...great Naveen!!
Very helpful..plz continue with such videos
Thank you sir for such amazing explanation 🙏
Thank you very much Naveen sir for these series.. Really helping a lot 😊
Glad to hear that 😀
Nice explaination ,, Thanks 👍👍
Thanks Naveen.Great initiative. Keep going.❤️❤️
Thanks 😊
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
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?
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
Love your work. Keep making videos❤️
The java compiler copies the instance initializer block in the constructor after the first statement super(). So firstly, constructor is invoked.
You are awesome.... Sir
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!
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 ?
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.
Very helpful video. Thank you so much 🙏🏻
Thanks for watching pooja. Hope you are doing well.
Thank you! Great explanation! ❤
Thanks for watching.
It's very helpful thank you :)
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
Thank you so much..
at 16:50>> answer will be static block and main, because object is not created so instance block will not be executed.
please give any real time scenario where we can use it in our script .
Thank you Naveen
Thank u guru
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.
Very helpful
Glad to hear that
Amazing 🤩
How to access the object created in static block in another class?
This is great
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
Yup right.
Nice one. Please create similar complex type interview questions on collection framework.
Naveen sir, how can we utilize the obj created in the static block , in another class?
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..?
naveen can u discuss testing mobile interview question and especially Appium automation
Sure I'll prepare one series on appium Interview questions
I have interview next Tuesday, i hope that u can send me some questions so i can prepare
Thanks @Naveen sir for this series
Glad to hear that
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?
u nailed it 🔥
Thank you Shiva
@@naveenautomationlabs kindly start the series of algorithm like backtracking greedy such on
Nice video,Please share interview questions on multithreading
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?
If we are creating an object of the class in the static block , how do we access it from another class?
Hi sir,
Why non static block execute before constructor?
sir in q5 we cant do anything in java if main method is not written...........
is the relationship between Java and HTML, CSS, python, XML please show me a program that is made with all these?
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?
what's the package Java practices doing in that programs
why? how does it matter? its a package name where class is present.
4th question is Singleton class?
Bhagwan aapko ek din Tesla ka CEO banaye .jinke sirf tweet karne se shares ke price badh jaate hai .
Hey Naveen can we call static method inside static block???
Yes, you can.
static {
System.out.println("hi");
test();
}
public static void test() {
}
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..
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.
Please provide your telegram link updated
Disliking this video is a crime.
About Question 2 , Isn't "System" an object ?
System is a class in Java, not an Object.
@@naveenautomationlabs ah i see, I'm learning java and your videos are a huge help, thank you for the reply.
please subtitle