Anyone to describe more about objects and classes | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Anyone to describe more about objects and classes

31st Jan 2018, 7:25 PM
Musa Enocy
Musa Enocy - avatar
4 Answers
+ 7
when you submit a question, name the language in the tags section so ppl find it easily to answer.
31st Jan 2018, 7:31 PM
Mazin Ayash
Mazin Ayash - avatar
+ 6
which language?
31st Jan 2018, 7:30 PM
Mazin Ayash
Mazin Ayash - avatar
+ 2
Making a class can be thought of as defining a data type, and an object can be thought of as a variable of that data type. Each object has its own set of variables that you put in the class, completely unique for it. Just like if you have 2 ints and change the value of one, the other one does not change. Methods are functions inside the object that can be used to interact with all of the variables in the object, including private ones. You call a method like this: objName.methodName(param);
31st Jan 2018, 9:19 PM
Jacob Pembleton
Jacob Pembleton - avatar
+ 1
@Musa Enocy 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, 4:00 PM
sai chaitanya nandipati