✔ Data Types: different types expain
Answers
Explanation:
A data type, in programming, is a classification that specifies which type of value a variable has and what type of mathematical, relational or logical operations can be applied to it without causing an error. A string, for example, is a data type that is used to classify text and an integer is a data type used to classify whole numbers.
Data Type
Used for
Example
String
Alphanumeric characters
hello world, Alice, Bob123
Integer
Whole numbers
7, 12, 999
Float (floating point)
Number with a decimal point
3.15, 9.06, 00.13
Character
Encoding text numerically
97 (in ASCII, 97 is a lower case 'a')
Boolean
Representing logical values
TRUE, FALSE
The data type defines which operations can safely be performed to create, transform and use the variable in another computation. When a program language requires a variable to only be used in ways that respect its data type, that language is said to be strongly typed. This prevents errors, because while it is logical to ask the computer to multiply a float by an integer (1.5 x 5), it is illogical to ask the computer to multiply a float by a string (1.5 x Alice). When a programming language allows a variable of one data type to be used as if it were a value of another data type, the language is said to be weakly typed.
Answer :-
Data types :-
- Primitive data type: byte short, int, long, float, double, char and boolean
- Composite data type: Arrays, class.
- User defined data type: The data types created by the user like a class is known as user-defined data type.