GamifiedGamified challengesPracticeRaceLeaderboardPricing

Learn data structures by watching them move, then doing it yourself. Press M anytime to toggle sound.

A product of Amypo Technologies, Coimbatore.

Learn

  • Fundamentals & OOPs
  • Data structures and algorithms
  • Aptitude
  • Learning path
  • How it works
  • About dotprep

Practice

  • Practice arena
  • Daily challenge
  • Gamified challenges
  • Race mode
  • Leaderboard

Interview prep

  • Java interview
  • Coding questions
  • Company questions
  • System design
  • Jobs & careers

You

  • Dashboard
  • Settings
  • Pricing
  • Create account

© 2026 dotprep

Content last updated 27 November 2026

GamifiedGamified challengesPracticeRaceLeaderboardPricing
Log inStart free

Free preview: 2 of 3 free topics used. You can open 1 more without an account.

Sign up free to unlock all 113
Fundamentals & OOPsProgramming fundamentals

Data types

beginnerevery value has a type: whole number, decimal number, text, or true/false
Before this: Variables, so you know that a value is kept in a named box.

1. The problem

Think of an admission form. The name blank takes letters. The age blank takes a whole number. The height blank takes a number with a decimal point. And 'Hostel needed?' is only a tick: yes or no. Nobody writes 'tall' in the age blank, and nobody tries to add two names together. A program has the same need. Before it can work with a value, it must know what kind of value it is.

How does a computer know whether a value is a number, some text, or a yes-or-no answer, and why does it matter?

2. Picture it first

An admission form has different kinds of blanks. The name blank takes letters. The age blank takes a whole number. The height blank takes a number with a decimal point. A tick box takes only yes or no. Values in a program are the same: each one has a type, and the type decides what you can do with it.

Every part of the picture has a name in code:

In the pictureIn code
A blank that takes letterstext, called a string: "Asha"
A blank that takes a whole numberint: 17
A blank that takes a number with a decimal pointdouble or float: 1.62
A tick box: yes or noboolean: true or false
Writing the first name and the surname togetherjoining text: name + " Kumar"
Reading the digits on a form as a real numberconverting: the text "25" to the number 25

3. Watch the story, built from zero

Story mode

Story mode

20 scenes · about 4 min · narrated
  • just created
  • being read or changed
  • blank not filled in yet

In real life

👧abcnameblank
🎂123ageblank
📏1.5heightblank
🗳️yes/noadult?blank

A student ID card. Each blank takes a different kind of value.

In the computer's memory

Variables

—

On the screen

Nothing printed yet

1public class Main {
2 public static void main(String[] args) {
3 String name = "Asha"; // text, in quotes
4 int age = 17; // whole number
5 double height = 1.62; // decimal number
6 boolean adult = age >= 18; // true or false
7 String full = name + " Kumar"; // + joins text
8 String typed = "25"; // text, not a number
9 int roll = Integer.parseInt(typed); // text to int
10 System.out.println(full);
11 System.out.println(roll + 1); // + adds numbers
12 }
13}

1 / 20
EnglishThis lesson is in English for now

4. On a paper form vs Data types

On a paper formData types
A nameLetters written in a blankText in quotes: "Asha"
An ageA whole numberint: 17, no quotes
A heightA number with a decimal pointdouble or float: 1.62
Adult or notA tick: yes or noboolean: true or false
A typed roll numberDigits, read as a numberText "25" until it is converted

5. Common mistakes

  • Putting quotes around a number you want to do maths with: age = "17".

    Quotes make it text. Write a number without quotes: age = 17.

  • Leaving out the quotes around text: name = Asha.

    Without quotes, the computer looks for a variable called Asha. Text always goes inside quotes: name = "Asha".

  • Doing maths with digits that were typed in or read from a file.

    Typed input arrives as text. Convert it first, with int(...) in Python or Integer.parseInt(...) in Java, and then do the maths.

  • Writing a boolean inside quotes: adult = "true".

    In quotes it is text, four letters long. The boolean is written without quotes: true, or True in Python.

6. Where you'll meet it

Phone numbers

A phone number is stored as text. You never add two phone numbers, and a number type would drop a zero at the front.

Prices and marks

These are stored as numbers, because a program adds them, averages them and compares them.

Switches in settings

Dark mode on or off, notifications on or off: each switch is one boolean, true or false.

Working with text

Text has many uses of its own: its length, its single characters, searching inside it.

See that lesson

7. Check yourself

Answer these before you watch it move. Each answer explains itself.

Question 1

1.Which of these values is text?

Question 2

2.name holds the text "Ravi". What does name + " Shah" give?

Question 3

3.typed holds the text "25". What must the program do before it can add 1 and get 26?

Question 4

4.marks holds 35. What type of value does marks >= 40 give?

In short

  1. 1Every value has a type: the kind of value it is.
  2. 2A whole number such as 17 is an int. A number with a decimal point such as 1.62 is a double in Java and C++, and a float in Python. JavaScript calls both of them number.
  3. 3Text is written inside quotes: "Asha". Programmers call text a string. The quotes show where the text starts and ends; they are not part of it.
  4. 4A boolean is either true or false, and nothing else. A comparison such as age >= 18 gives a boolean.
  5. 5The type decides what an operation does. Between two numbers, + adds. Between two texts, + joins them end to end.
  6. 6Text made of digits, such as "25", is still text. Convert it to a number before you do maths with it.

On this page

  • The problem
  • Picture it first
  • Story mode
  • Compare
  • Common mistakes
  • Where you'll meet it
  • Check yourself
  • In short

Key facts

Whole number
int: 17
Decimal number
double or float: 1.62
Text
string, in quotes: "Asha"
True or false
boolean: true, false
Text to number
convert first: "25" → 25

When to use it

Every time you create a variable, ask what kind of value it holds. Marks and prices are numbers because you do maths with them. Names, addresses and phone numbers are text. Anything with only two possible answers, such as passed or not, is a boolean.