+ 3
[Java] Can we create an instance of a static class?
^ Can we create an instance of a static class? I read that all top-level classes are, by definition, static. And inner static classes can be instantiated, without an living instance from the top-level class. But inner non-static classes cannot be created without an instance from the top-level class. There was a challenge question: Objects or instances of the following cannot be created. [X] Abstract class [] final class [X] Interface [X] Static class I am wrong or is this challenge question wrong?
4 Antworten
+ 3
yes, we can create instance of a static class
https://code.sololearn.com/cutBYJU4Xn4c/?ref=app
+ 3
🇮🇷 M N
so the challenge was wrong, again..
+ 2
it seems that the challenge is wrong
+ 2
In interface two nested class are allowed..
static nested classes
and
Anonymous classes...
..
I dont think so
we can do that..(what u asked)