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 the difference between swing and awt in java?
What is import javax swing in java?
Why should the implementation of any swing callback (like a listener) execute quickly?
What is an event in Swing?
Is swing part of core java?
What are heavy weight components ?
What is the what is the difference between invokeandwait() and invokelater()? ?
What is the design pattern that java uses for all swing components ?
Why swing is used in java?
How to link two forms in java swing?
What is swing gui?
What is jfc? What are the features of jfc?
What is the difference between swing and awt?
How does accessibility works in swings?
What is a swing day?