can we create a object in static block
class A
{
static {
A a=new A();
}
}
Answer Posted / karthik
We can create object because static block is a executable
block and we don't want any Instance to call. It will be
called before executing or calling the main thread
But here we will get object and exception
//Exception in thread "main" java.lang.NoSuchMethodError:
main
Is This Answer Correct ? | 6 Yes | 6 No |
Post New Answer View All Answers
Is swing thread-safe?
What is the difference between a scrollbar and a jscrollpane ?
How to perform action on button in java swing?
What is jpanel swing?
How is multi-threading gets implemented using swing?
Why are swing components called lightweight components?
What are the containers available in swing?
What is import javax swing jframe?
How do you swing an applet?
What is jfc swing in java?
How to reload a jframe in java swing?
What is the difference between swing and awt?
What is the process of setting the layout manager?
What class is at the top of the AWT event hierarchy?
Why swing is better than awt?