+ 2

Why two classes for objects

Can you reming me why do we create myclass and without it object does not work(outputs error)? I get that Vehicle class has attributes and methods which can be used in objects Objects are created using "new" method (if I understood this correctly) So the objects of Vehicle class are created in different class (in this app we use MyClass to define objects)? Is it a must? Why? 1.Does it mean that main class is Vehicle and sub class is MyClass which holds objects inside of it? 2.Does it mean that MyClass is object of Vehicle class? 3.If It is true so object of Vehicle class has attributes and methods upon which we make actions? 4.So main method is used for execution of actions and is put only in these classes which are "bottom"? 5.So OOP is like a pyramid, from top to bottom mostly times expanding? Kindly let me connect the parts in my head by confirming or explaining the details Thx

23rd Sep 2016, 11:22 AM
Bronius
Bronius - avatar
2 Respuestas
+ 2
the objects linked to "myclass" will not work because thy wont have a class to reference to once they are needed to b used... So if the "myclass" is missing in your program no object created from that class will b able to work at all hope i hve answered u well
24th Sep 2016, 10:52 AM
ddumba collins
ddumba collins - avatar
0
Bases of our program: There are two classes in our program... First class of vehicle, we created it to create a method, And why we create the method, see below: Instead of writing simple statement, We can write a method once and use it mutiple times without having to rewrite the code each time. And based on the parameters, methods can perform various actions. Therefore we create a method's class Now go on to the next step. There is 2nd class is myclass of main method. All of our statements store into main method. As you read in your previous lesson... I hope, you understand it. Like it, if its the better answer for you...
28th Sep 2016, 12:31 PM
Jai Vohra
Jai Vohra - avatar