can we create object for static class in java
Answer Posted / 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 View All Answers
How do you replace all in word?
What is jit compiler in java?
What is the console in java?
Why java is made?
I want to re-reach and use an object once it has been garbage collected. Define how it’s possible?
What is core java used for?
What are the common uses of "this" keyword in java ?
What is the collections api in java programming?
What is the use of inner class?
What are the differences between string and stringbuffer?
How will you initialize an Applet?
How can a gui component handle its own events?
How to declare an arraylist in java?
What is the difference between a window and a frame in java programming?
Why parameters should be passed by reference?