+ 3

Distinction between the class and object

Many beginning programmers may not see the distinction between the class and object. Can you explain?

31st Jan 2018, 8:22 AM
Keraznam
Keraznam - avatar
6 odpowiedzi
+ 18
https://www.javatpoint.com/difference-between-object-and-class
31st Jan 2018, 9:08 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 9
Imagine a class to be a blueprint. Using that blueprint, you can create as many buildings as you wish. In that case, buildings will be objects. Again, imagine you are creating a multiplayer game.So there will be multiple players with same characteristics(Like moving,hitting). So you'll have to create the player class and instantiate 2 objects of that class. Finally check out this article.... https://www.ncl.ucar.edu/Document/HLUs/User_Guide/classes/classoview.shtml
31st Jan 2018, 9:12 AM
Md. Nafis Ul Haque Shifat
Md. Nafis Ul Haque Shifat - avatar
+ 6
Let's have a case of a car, when you think about a car you would know some characteristics; it runs on fuel/electric, has four wheels, carries at least 2 passengers, your idea about it is the car class. Based on that idea you can then create a real car, which is an instance of the car class (we dub it object). The process of transforming an imaginary car class into a real formed car is called instantiation. Without the car class you wouldn't know how to create a real car, you just have no clue what to do. There is a little difference in programming though, modern language such as Java supports a feature that separates a class' member from its instance's, these feature allows some members of the class to be accessible or usable without the need to create an instance, but I guess it's out of scope : ) Hth, cmiiw
31st Jan 2018, 9:16 AM
Ipang
+ 3
Read it , this may be helpful:- Class is like template consider an example like you have blueprint of house which is on paper but not yet existed, when you implement blueprint to build a house in real world you can call it an object, house will have all the features which will be mention in its blueprint and an address where it is located. Same like above example, create your class defining variable and method according to need of your program , your class is like template it is not existed yet but when you will create an object of your class, object will store reference in memory(address) and now instance of your class will be created(exist in real), which will have everything as mention in class, now through object you can access method and var of created instance. classes in oop approach provide several benefits: like code organization creating separate classes, provide abstraction, encapsulation and many more oop features..
31st Jan 2018, 12:32 PM
Amrendra Kumar
Amrendra Kumar - avatar
+ 2
@Keraznam Object is an instance of a class. Basically you can think of class as a data type and object as a varible.When we create an object from a class object will have access to all the data(variables) and methods(functions) of the class. EX: a BANK is class and it might have data (variables) like name, DOB, address, totalAmount etc and methods (functions) can be display amount, display account details, transfer etc. And we can think all the account holders in the BANK as objects. Every member(object) will have access to all the data and methods of the BANK(class) and their data is hidden(encapsulated) from other account holders(objects).
1st Feb 2018, 3:56 PM
sai chaitanya nandipati