Previously we have discussed the Program for
This is most important interview question ,That Java Program can run without main method or not ? The answer is Yes Program can run without main Method using static Block. Static Block run before Constructor calling.And to run Static Block we do not need to create any Object.
public class WithoutMainMethod {
static{
System.out.println("** INSIDE STATIC BLOCK **");
}
public static void main(String[] args) {
}
}
Java I/O Tutorial
No comments:
Post a Comment