+ 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?

2nd Apr 2018, 9:57 AM
Steinchr der Wahre
4 ответов
+ 3
yes, we can create instance of a static class https://code.sololearn.com/cutBYJU4Xn4c/?ref=app
2nd Apr 2018, 10:42 AM
🇮🇷 M N
+ 3
🇮🇷 M N so the challenge was wrong, again..
2nd Apr 2018, 10:46 AM
Steinchr der Wahre
+ 2
it seems that the challenge is wrong
2nd Apr 2018, 10:57 AM
🇮🇷 M N
+ 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)
2nd Apr 2018, 9:04 PM
Arun Tomar
Arun Tomar - avatar