0

can someone please help explain to be how objects work.I just want to get a better understanding so any example will help.thanks

28th Dec 2016, 7:06 PM
Samson Adewale
Samson Adewale - avatar
4 Answers
+ 2
Objects are well, objects. Programming-wise, they are a representation of anything that has attributes and behaviors. For example, a bycicle could be represented in a Bycicle object. For doing so, Bycicle would need to be encapsulated in a class. A bycicle has speed, a bycicle has a number of seats, gears, the gears states and it can brake and move. So, there could be a class like this (in Java) Class Bycicle { public int speed; public int seats; public int gears; public int gear_state; public void brake(){ speed =0;} public void move() {speed++;} Public void Bycicle (seats, gears){ this.seats= seats; this.gears= gears; } } And when you instantiate this object(create a new Bycicle), say: Bycicle cool bike = new Bycicle(1,18); You make a representation of a bycicle, in other words, a data object that represents a bycicle. In that context, Bycicle is treated as an object and has both attributes and behaviors that we can use to represent it.
29th Dec 2016, 4:30 AM
Leon Nascimento
Leon Nascimento - avatar
+ 1
a class is like a male..he always have a name and description(attributes) and he can do things (functions)...if you make any body a man you should give him such specifications(name,description,abilities to do sth)..so you define him as an object of the class "man" and specify his atteibutes...😊
28th Dec 2016, 9:42 PM
Ahmad S Kanaan
Ahmad S Kanaan - avatar
+ 1
am guessing in programming clasd specifications would be things like methods, functions and variables, constructors and properties (just learned on sololearn) inside of the class. and then as for an object am guessong this is simple using the class and all its mentioned specifications??
29th Dec 2016, 6:50 PM
Samson Adewale
Samson Adewale - avatar
+ 1
@OP, there's a saying that claims that a Class is just an Object that hasn't been instantiated yet.
29th Dec 2016, 6:57 PM
Leon Nascimento
Leon Nascimento - avatar