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 awt and swing in java?
Is java swing deprecated?
How do you swing an applet?
What are controls and what are different types of controls in awt?
What are the advantages of the event-delegation model over the event-inheritance model?
Which layout does swing use by default?
What are the different components that are used to show a container?
How to create image slideshow in java swing?
What is the class in swing to change the appearance of the frame in runtime?
What is content pane in swing?
When we should go for codebase in applet?
What is the function of lightweight components used in swing?
What is pane in swing?
What are swings awt?
Explain the difference between swing and jsf.