+ 2

What is the diferencce between CLASS and Objects on Java??

4th Dec 2016, 12:34 PM
Gilson Gomes De Oliveira Junior
Gilson Gomes De Oliveira Junior - avatar
5 Réponses
+ 4
If you know javascript think a class in java as a function in javascript. And think object as a var. here you only just have to use the "new" keyword. Look at the syntax and figure out the difference yourself. class myclass { } object myobject = new myclass(); see both are different.
4th Dec 2016, 12:53 PM
Cyrus Ornob Corraya
Cyrus Ornob Corraya - avatar
+ 3
Class are the definition, where you put all the atributes and methods, the mould. Objects are instances of a class. They have all the moethods and atributes from their classes. Example: you have the class Person, and the object p1 , wich is a Object , with type Person. Person p1 = new Person();
4th Dec 2016, 12:42 PM
Nahuel
Nahuel - avatar
+ 2
You can think of classes like a blueprint. For example the blueprint of a house, 4 windows, 2 doors, 4 walls, a roof, etc. You use the blueprint to build houses. The houses would be the objects.
4th Dec 2016, 2:23 PM
Jose Ayala
Jose Ayala - avatar
+ 1
I wouldn't say that the class contains the objects but rather the class defines the objects. A Car class might define what a car is or has such as steering wheel, doors, wheels, engine, but the objects are the cars, BMW, Mercedes, Ford, Toyota, etc...
4th Dec 2016, 8:43 PM
Jose Ayala
Jose Ayala - avatar
0
the class contains the object. It's correct??
4th Dec 2016, 1:22 PM
Gilson Gomes De Oliveira Junior
Gilson Gomes De Oliveira Junior - avatar