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
What is swing package in java?
What is an event in Swing?
Why is model-view-controller architecture used in swing?
What is the difference between invokeAndWait() and invokeLater()?
What is the difference between swing and awt?
What is the use of java swing?
What is awt and swing in java?
What is swing and awt in java?
How is parsing html used in swing?
What are the benefits if Swing over AWT?
How to render an html page using only swing.
What are the different components that are used to show a container?
What is a swing day?
What do you mean by java swing?
Which layout does swing use by default?