can we create object for static class in java

Answers were Sorted based on User's Feedback



can we create object for static class in java..

Answer / soma414@gmail.com

yes we want create the object by using static class in java

Is This Answer Correct ?    0 Yes 0 No

can we create object for static class in java..

Answer / manjula

yes we can able to create object for the static class.. but
it is none of use.. because we can call the static class
without creating the object

Is This Answer Correct ?    0 Yes 0 No

can we create object for static class in java..

Answer / faisal

Yes you can instantiate a static inner class and it makes sense. Internal working of hash map and hash table is based on same

Is This Answer Correct ?    0 Yes 0 No

can we create object for static class in java..

Answer / santosh vyavhare

We can create a object of "static nested class ".
For eg. class Abc{
static class X{
void m()
System.out.println("static nested class method");
}
public static void main(String[] a)
{
X x=new X();
x.m();
}
}


but if you can not declare outer class as a static if u try to make outer class as static it will generate compile time error.
For eg static class X{}
It will generate compile time error as "Illegal modifier for the class".

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

Why can't we make a class private in java?

0 Answers  


Which is faster call by value or call by reference?

0 Answers  


suppose in a class there is a code like this: { Set hs=new Hashset(); hs.add(new Emp("kathy",1000)); hs.add(new Emp("kathy",2000)); } how can u avoid the above code in your class as set won't allow duplicate objects?

3 Answers  


What is java thread dump, how can we get java thread dump of a program?

0 Answers  


What is size of int in java?

0 Answers  


Difference between overriding and overloading in java?

0 Answers  


which class to use when concatenating strings in a loop.

3 Answers   IBM,


can java object be locked down for exclusive use by a given thread? : Java thread

0 Answers  


Describe the syntax of multiple inheritance? When do we use such an inheritance?

0 Answers   Fidelity,


What package is math in java?

0 Answers  


Is hashset sorted in java?

0 Answers  


What does nextint () do in java?

0 Answers  


Categories