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 the final keyword denotes?
What is variable length arguments in java?
What is arraylist e in java?
What are strings in physics?
Can a constructor be protected?
What does exp mean in math?
What is difference between c++ and java ?
What language is an assembler written in?
Explain about class in java?
Can we override singleton class?
What is a generic type?
How to Sort Strings which are given in List and display in ascending order without using java api.
What does percent mean in java?
Given a singly linked list, how will you print out its contents in the reverse order? Can you do it with consuming any extra space?
What are Normalization Rules? Define Normalization?