What is The Importance of Using Classes ????.....It 's Sounds Kinda Like Methods | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is The Importance of Using Classes ????.....It 's Sounds Kinda Like Methods

12th Aug 2016, 5:18 PM
Mahmoud Hamdy Abaza
Mahmoud Hamdy Abaza - avatar
3 Answers
+ 2
I'll try to keep it simple, but classes play a huge role in object oriented programming. First, duplication. With classes, you can have multiple objects without having to type out the specifics of each one. One class, multiple objects can be created from it. Encapsulation. Hiding data from users. With classes, you can have private variables and public methods so you can control what the user can do/see with the variables. Polymorphism. Allowing one class to use aspects of another to fill its role. Could make this a lot longer, since it's a lot to talk about. But hope you get the idea. Classes are not like methods.
13th Aug 2016, 2:34 AM
James
James - avatar
0
ThanX James xD
13th Aug 2016, 2:43 AM
Mahmoud Hamdy Abaza
Mahmoud Hamdy Abaza - avatar
0
Class is like a template, which can be used for an object (e.g. savings account, car) these are objects. For a savings account, you can create a class. A savings account have the attributes namely account#, pin, balance. And on these attributes, we can perform some operations which are eventually achieved by methods
13th Aug 2016, 3:28 AM
Varun Negi
Varun Negi - avatar