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 is java swing package?

509


What are the advantages of swing over awt?

493


What are heavy weight components ?

616


What are the components of java swing?

521


What is the use of jfc in java swing?

652






Why swing components are called lightweight components?

504


What is swing components in java?

518


What is import javax swing?

512


What are the two key features of swing?

528


Is there any heavyweight component in swings?

513


Is swing still used?

495


What is swing gui?

502


What are the advantage of swing over awt?

499


What is swing framework in java?

548


What is the use of double buffering in swings?

553