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
Explain the pointers in Java?
Why do we need hashmap in java?
What does serializing data mean?
What do you understand by the term polymorphism?
What is variable and example?
Explain working of call by reference function invoking.
What is length in java?
What is constructor chaining in java?
Can you pass by reference in java?
What are the principle concepts of oops?
What are the states of thread in java?
Why java is called not pure object oriented language?
Can you declare an interface method static?
How is treeset implemented in java?
What is the difference between error and an exception?