Computer Science, asked by sehjshsh, 11 months ago

Why class is a user defined data type...?? ​

Answers

Answered by charlie1505
0

Explanation:

User-defined classes are common to object-oriented programming and are used to represent objects whose data can be protected, initialized, and accessed by a specific set of procedures.

User-defined data types and classes can both contain multiple variables of different data types. Unlike user-defined data types, classes can also contain procedures (properties and methods) that operate on those variables.

You can extend a class but not a user-defined data type. That is, you can derive new classes (called derived classes) from an existing class (called a base class), where the derived classes inherit from the existing (base) class. For example, you could extend an Employee class by creating a FullEmployee class to represent full-time employees and a Contractor class to represent temporary employees. Both the FullEmployee class and the Contractor class share common data (ID, lastName, firstName, payCheck) provided by the Employee class.

Another important difference between user-defined data types and classes is that a variable of a user-defined data type holds actual data, while a class's object reference variable points to an object's data stored in memory. For example, Person1 and Person2 can be object reference variables that point to the same CheckingAccount object. This flexibility allows two different people to access the same checking account.

Demonstrates the Person 1 and 2 object reference variables of the CheckingAccount object

In general, you create a user-defined data type for operations that don't need properties and methods. For example, you might create a data type named Coordinates that contains member X and Y coordinates in order to perform simple file read/write operations. In most other cases, you will want to create classes.

Answered by riddhilahiri04
0

Answer:

well simply, a class is created by users....it is a composite data type, composed by the user consisting a number of primitive data types, and more over, the size of a class is variable, not fixed like that of primitive data type.

hope you understand...and if not, you can ask in the comment section..

please mark my answer as brainliest!!

Similar questions