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


Please Help Members By Posting Answers For Below Questions

What are the benefits of swing over awt?

586


What is import javax swing * used for?

556


Is swing an adjective?

552


What is the class in swing to change the appearance of the frame in runtime?

560


How to create a swing gui in java?

528






What is the design pattern that java uses for all swing components ?

507


What is swing control in java?

546


How is parsing html used in swing?

560


What is swing in java with example?

506


Write a program to include the internal frame in swing.

545


How to align components in java swing?

579


What is jfc? What are the features of jfc?

616


Which layout does swing use by default?

496


What are the components of java swing?

524


What are controls and what are different types of controls in awt?

523