1.

What are the various data types available in Kotlin? Explain them.

Answer»

Primitive data types are the most BASIC data types in Kotlin, and all others are reference types like array and string. Kotlin contains all data types as objects. FOLLOWING are the different data types available in Kotlin:-

Integer Data Type -

Data TypeSpace Required
byte8 bits
short16 bits
int32 bits
long64 bits

Floating Point Data Type - 

Data TypeSpace Required
float32 bits
double64 bits

BOOLEAN Data Type - 

True or false is the only bit of information represented by the Boolean data type. In Kotlin, the Boolean type is the same as in Java. 

Data TypeSpace Required
boolean1 bit

Character Data Type - 

Small letters (a-z), capital letters (A-Z), numerals (0-9), and other symbols are represented by the character data type.

Data TypeSpace Required
char8 bits

String Data Type -

Strings are represented in Kotlin by the type String. A string value is OFTEN a sequence of characters enclosed in double quotations ("). The space required in this CASE depends on the number of characters in the string.

Array Data Type -

The Array class in Kotlin is used to represent arrays. It has the get and set functions that, due to operator overloading conventions, can be used as  ‘[]’  as well. The space required by the array also depends on the number of elements it posses.



Discussion

No Comment Found