Can we get a different Output without changing the main-method definition?public class HelloMain {/*** @param args*/public Static void main(String[] args) { System.out.println("Mr. main.");}}Can we have the output of the above code-segment as "Hi, Mr. main. Bye!" without changing the main-method code?Yeah, we can have the required output by using 'static initializer' blocks effectively. As we
This post first appeared on Geek Explains: Java, J2EE, Oracle, Puzzles, And Problem Solving!, please read the originial post: here