can we create a object in static block
class A
{
static {
A a=new A();
}
}

Answer Posted / srinu

Yes we can create a object in static block
EX:-

public class Stobject
{
static
{
Stobject st =new Stobject();
}
Stobject()
{
System .out.println("object created");
}

public static void main(String k[])
{
System .out.println("HAI");
}
}
output:-
object created
HAi

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the two key features of swing?

528


Where is java swing used?

580


Explain the difference between awt and swt.

547


What are swings?

515


What is the base class for all swing components?

604






Why are swings considered lightweight?

542


What's java swing?

565


What are swings awt?

546


How to generate bill in java swing?

682


What is content pane in swing?

520


What are swing components?

593


Hello Everyone.. I m trying to develop a java swing application where i can display a doc file Jeditorpane or Jtextpane.

1753


Why swings are called lightweight components?

523


What is actionlistener in java swing?

535


What is the use of java swing?

524