+ 12

please explain objects and classes in simple manner like you are teaching to 5 year old !

in simple language please :)

19th Feb 2018, 10:41 AM
Jay Jay
Jay Jay - avatar
9 Answers
+ 19
You, including your mind, beliefs, and physical self are a class. Your mind is an object. Your arms, legs, torso, head, shoulders, hands, and feet are objects. These things would be defined within the class, likely under a function/method called __init__, or something similar, followed by more functions that operate on the individual objects. A method is a function defined within a class. A method in the example class above could be to raise your hand. Another method could be to walk forward one step. All of these things are within the example-class mentioned above. Think of it as something like ... a master function that holds data as well as more functions.
19th Feb 2018, 10:49 AM
Fox - avatar
+ 13
In my opinion (my opinion maybe a little bit confusing) You can imagine CLASS as a classroom. OBJECTS are students.
19th Feb 2018, 1:26 PM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar
+ 11
I hope this help you. 1) Object is an instance of a class. Class is a blueprint or template from which objects are created. 2) - Object is a real world entity such as pen, laptop, mobile, bed, keyboard, mouse, chair etc. - Class is a group of similar objects. 3) - Object is a physical entity. - Class is a logical entity. 4) - Object is created through new keyword mainly e.g. Student s1=new Student(); - Class is declared using class keyword e.g. class Student{} 5) - Object is created many times as per requirement. - Class is declared once. 6) - Object allocates memory when it is created. - Class doesn't allocated memory when it is created. 7) - There are many ways to create object in java such as new keyword, newInstance() method, clone() method, factory method and deserialization. - There is only one way to define class in java using class keyword.
19th Feb 2018, 10:55 AM
J Domingo Jiménez J
J Domingo Jiménez J - avatar
+ 5
thanks for your time writing this answer
19th Feb 2018, 10:48 AM
Jay Jay
Jay Jay - avatar
+ 5
From programming aspect, Keep in mind that a class includes some variables and some functions: Now, you can create numerous objects of that class and use the class variables and functions as object METHOD. for example: consider that you wanna declare a class of cars called myclass. asume that each object(specific car) of this class should have a specific function and color. Car1 is the first object of myclass and we call it object1. it has a function and a color. Car2 is the second object of myclass and we call it object2. it has a different function and different color. class myclass { int function(int x){...} int color; }; int main (){ myclass object1; a=object1.function (3); object1.color=20; myclass object2; c=object2.function (5); object2.color=100; return 0; } Now you can see how a realistic example can be converted to a programing language. class variables(for our example, colors): ------------------------------------------------------------------ The variables that we declare in a class can be accessed in main() function when you declare an object of that class (myclass myobject;). then, the class variable can be used/called as the object method (myobject.variable). class functions: --------------------------- The functions that we declare in a class can be accessed in main() function when you declare an object of that class (myclass myobject;). Then, class function can be used/called as the object method (myobject.function). also keep in mind that this was a very simplified application of a class and objects. ---------------------------------------- Vote up if it's useful... ❤️ ----------------------------------------
19th Apr 2018, 8:41 AM
Amirashkan - avatar
+ 2
think of a class as a project of some machine. when u make a machine according to that project, you made an object that is an instance of that class. and this object now inherits all properties (material, color, name...) and methods (speaking, jumping, raising hand...) from that class
19th Feb 2018, 12:17 PM
Dominique Abou Samah
Dominique Abou Samah - avatar
+ 1
Class is blue print from which object are created... For example if any building is constructed then firstly its map is created how to build that house and different attribute like room, bathroom, hall etc is defined or mapped in the map so here the map of building is class and different rooms in the building is object.
24th Jun 2019, 3:14 PM
anuradha mall
19th Apr 2018, 9:20 AM
Jay Jay
Jay Jay - avatar
simple and clear explanation.
17th Aug 2018, 8:00 AM
Boniface Musonda
Boniface Musonda - avatar