Computer Science, asked by minishelare6095, 1 year ago

How do classes help to organize programs in java?

Answers

Answered by RahulMalkani
4
Classes are the blue print of an object. This is the basic book definition. But most specifically, OOPS came into existence to make it easier to organise real world entities like students, teachers etc in an systematic way.

Let's talk about real world entities (Eg. students, books, cars etc). Every entity in this world has two things: Characteristics and Behaviour.

Every entity has some characteristics which make it different from other entities. For example: A student can have many characteristics like name, roll number, gender, class, age and etc.

There are some behaviours associated with an entity like getting roll number, name or age of that entity.

Now come to classes, classes are the best way to represent a real world entity. I assume you know the basic concepts of classes, if not let me know via reply. Classes have data members and functions in it.

Here, data members reassembles the characteristics of a entity and functions reassembles the behaviours of it.

Like, if you have to create a student class. You will create a class with data members (name, roll no, age, gender etc) and some functions for getting the value of these data members like getName() which will return the name of the student.
You can understand know why classes are the best way to organise programs. By using the word blue print, what I mean is now you can use that class to create as many student objects you want to create just fill the data member fields with new student details every time.
Similar questions