Elaborate more about classes, Object and Methods for Java programming Language | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 2

Elaborate more about classes, Object and Methods for Java programming Language

With the help of real-life analogy, explain what are classes, objects, and methods as used in object-oriented programing? * Your answer

3rd Oct 2021, 10:57 PM
Muhammad sani
Muhammad sani  - avatar
2 Answers
+ 1
Imagine you have a class Car in GTA 5, and you are one of the programmers. You create a Car object(Car c1=new Car(blue, sanchez)). Then you start it(c1.start()). Then you make it go random ways so that the player doesn't feel alone(c1.goRandom())(usage of method "goRandom()" here). And if the user enters cheat bigbang, you blast the car(c1.explode())(usage of another method). Hope my example makes sense😗😇 This is how I always imagined using object oriented programming languages like Java and C++ and etc...
4th Oct 2021, 2:11 AM
Rishi
Rishi - avatar