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
What is int argc char * argv?
What do you mean by singleton class in java?
What is Java Reflection API? Why it’s so important to have?
What is a class object?
What loop means?
What is a package in java? List down various advantages of packages.
How do you decide when to use arraylist and linkedlist?
How would you convert bytes to string?
Can you pass functions in java?
What is collection sort in java?
Is it possible for a yielded thread to get chance for its execution again?
What is consumer interface?
Can memory leak happen java?
Explain the different forms of polymorphism?
If two threads have same priority which thread will be executed first ?