why In Java, every line of code that can actually run needs to be inside a class?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

why In Java, every line of code that can actually run needs to be inside a class??

there was no need of class to run a c or cpp program.then why in java, class is used?

18th Oct 2017, 4:45 PM
sumit kumar dash
sumit kumar dash - avatar
1 Answer
+ 9
Classes come along with object-oriented programming. C isn't an OOP language, and C++ isn't solely OOP, it's a multi-paradigm language, so it isn't bound to only the rules of OOP programming. Java is an OOP language, so all things are objects, which are instances of classes. Hope that helps explain it for ya. Let me know if you need further elaboration.
18th Oct 2017, 5:09 PM
AgentSmith