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

What is number data type in java?

0 Answers  


How many days will it take to learn java?

0 Answers  


How to declare unique ArrayList ?

6 Answers   RMSI,


Is null function in java?

0 Answers  


How do you make a thread in java?

0 Answers  


What is numeric promotion?

1 Answers  


what is object slice?

2 Answers   HTC, TCS,


When should I use abstract classes and when should I use interfaces?

2 Answers  


What is a nonetype?

0 Answers  


What is nan in java?

0 Answers  


Why is serialization required?

0 Answers  


What is the need of transient variables in Java ?

0 Answers   MCN Solutions,


Categories