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
What is import javax swing?
What is layout in java swing?
How to perform action on button in java swing?
What is an event in Swing?
How to align components in java swing?
Which is better swing or awt?
What is jpanel in java swing with example?
What are swings awt?
Which layout does swing use by default?
What is the function of abstractaction class?
What is a swing application?
What is java swing package?
What is the function of internal frame in swing?
How to render an html page using only swing.
What is the process of setting the layout manager?