is it neccesary to create a class in java | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

is it neccesary to create a class in java

1st Jul 2016, 3:59 AM
Nishant Sardana
Nishant Sardana - avatar
4 Answers
+ 3
yes, it is. you should at the very least have the main class.
1st Jul 2016, 6:22 AM
Jasper Ro
Jasper Ro - avatar
+ 3
yes each and every code in java is written inside the class.When the program is compiled . java file is translated into .class file.So when we execute a class jvm finds the corresponding .class file of that particular class and executes it
1st Jul 2016, 7:38 AM
Sagar Agrawal
Sagar Agrawal - avatar
+ 2
since java is %100 object oriented so everything is an object, every object uses a class as the blueprint to create the object, you have to have a class.
2nd Jul 2016, 5:13 AM
Dwayne Barsotta
Dwayne Barsotta - avatar
+ 1
agree class is mandatory
3rd Jul 2016, 3:44 AM
‎‏‎‏‎Joe
‎‏‎‏‎Joe - avatar