I want to print 'Hello' even before main() is executed. How will you acheive that? Ans. Print the statement inside a static block of code. Static blocks get executed when the class gets loaded into the memory and even before the creation of an object. Hence it will be executed before the main() method. And it will be executed only once. - Study24x7
Social learning Network
study24x7

Default error msg

Login

New to Study24x7 ? Join Now
Already have an account? Login
12 Oct 2023 09:57 AM study24x7 study24x7

I want to print "Hello" even before main() is executed. How will you acheive that? Ans. Print the statement inside a static block of code. Static blocks get executed when the class gets loaded into the memory and even before the creation of an object. Hence it will be executed b...

See more

study24x7
Write a comment
Related Questions
500+   more Questions to answer
Most Related Articles