0

why need to create new object inside main function?

Why we need to create new object inside main function to call function from other classes? Can we just use import and call it direcly? ex: vehicle.running(); instead vehicle car = new vehicle(); car.running(); The result printed on the screen same.

6th Aug 2018, 4:30 AM
Sony Jocom
Sony Jocom - avatar
2 Antworten
+ 1
Class is like a design drawing. Object is made from it. The design drawing of the vehicle doesn't run like a car, does it? (But static methods can be called without its object.)
6th Aug 2018, 4:36 AM
Disvolviĝo;
Disvolviĝo; - avatar