ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Java J2EE  >>  Java Related  >>  Swing
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
can we create a object in static block
class A
{
static {
A a=new A();
}
}
 Question Submitted By :: Rajender
I also faced this Question!!     Rank Answer Posted By  
 
  Re: can we create a object in static block class A { static { A a=new A(); } }
Answer
# 1
Yes, we can create a object in static block
 
Is This Answer Correct ?    4 Yes 0 No
Chellammal
 
  Re: can we create a object in static block class A { static { A a=new A(); } }
Answer
# 2
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 ?    3 Yes 4 No
Karthik
 
 
 
  Re: can we create a object in static block class A { static { A a=new A(); } }
Answer
# 3
Yes we can do this . Because we can create an object at
runtime and  static block is also execute when a class is
loaded by  the class loader at runtime
 
Is This Answer Correct ?    1 Yes 0 No
Naresh Tuhania
 
  Re: can we create a object in static block class A { static { A a=new A(); } }
Answer
# 4
Yes we can create a object in static block.
1- if there is no main method than it will compile easily but at run time it will throw exception 
//Exception in thread "main" java.lang.NoSuchMethodError: 
main
2- if we put main method inside the class then it will compile and run successfully and we will get object.
 
Is This Answer Correct ?    2 Yes 0 No
Kaushal Mittal
 
  Re: can we create a object in static block class A { static { A a=new A(); } }
Answer
# 5
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 ?    0 Yes 0 No
Srinu
 

 
 
 
Other Swing Interview Questions
 
  Question Asked @ Answers
 
I want to change the appearance of Frame in Runtime, what class can be used to do this? Wipro1
Name the borders provided by Swing? Accenture1
What is meant by Swing?  4
What are the features of JFC?  1
what are the root classes of all classes?  4
how can u handle runtime exceptions in java plz explain with examples briefly? Fujitsu2
What is the base class for all of swing components?  3
Difference between ligt weight and heavy weight?  3
What is JTable and what is its purpose?  3
When i m clicking on next another frame is open but i want to hide the previous frame...........but it is not happening....still both frame are visible........how to make one frame to hide.......please help me.......  2
What does x mean in javax.swing?  4
What is the corresponding Layout for Card in Swing? Patni2
What are all the components used in Swing?  1
what is difference between checked and unchecked exception plz explain examples ? Fujitsu2
What is meant by JFC? Mindlogicx5
What are the benefits of using Swing over AWT?  1
what do u mean by GUI framework  1
What are tab pans?  3
Difference between AWT and Swing compenents?  2
Name the method, to expand & collapse nodes in a Jtree? Wipro1
 
For more Swing Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com