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
Is Constructor possible in abstract class in java ?
What are the 6 mandatory procedures for iso 9001?
Does a class inherit the constructors of its superclass in java programming?
What is casting in java programming?
Is 64bit faster than 32 bit?
Implement two stacks using a single array.
What do you know about the garbate collector?
What is widening and narrowing in java? Discuss with an example.
What’s meant by anonymous class?
How many boolean functions are there?
Does java runtime require a license?
hi am an engineering student and my next plan is for ms in either in us or australia i got my passport but i dont know anything bout visa can u give brief idea 1)How to get prepared for visa and 2)How to apply for top universities and 3)How to pay the fee and so on These all are basic questions plz give me a clear idea
What is string pooling concept?
How can you set the applet size?
What is pojo class in java?