Skip Top Navigation Bar

Determine a Data Type

Overview

In this lesson, students will begin to develop an understanding of the different types of data that are stored by the computer.

Learning Objectives

Skills

Student Outcomes

Students will be able to:

Duration: 1 class period

Resources

Background

A computer takes in input (data), stores it, processes it, and then outputs the new data. It's all about data. That is the source and life of any program. Consider some of the following popular programs you might be using:

Let's also consider a program that would be used to Analyze Data. The input would be data from a database. The program would store this data in a list. The program would then process the data to answer a question someone might have about the data. The output would be the answer from this analysis.

Discussion

Ask students to think of a game that they play regularly, either on their phone or on the computer (they could also use the board game they played to generate an algorihtm). Have them pair up with another student that has the same game. Students may need to change their game of choice to a different one so that all students are in groups of 2 - 3. Set a timer for 2 minutes and have students individually list the data that the program uses to run. Now that they have a list of data, ask them to take 2 minutes to individually catalog where this data originates from. Is the data:

Have students share their lists and classification, refining the list with their partner. Have the pairs create 1 slide with the name of the game and then four columns, one for each data source, listing the data in each column. Print these out and have students hang them up in the room.

Have students do a gallery walk with post-it notes to add comments related to data that might have been forgotten and needs to be added.

Primitive Data

Java divides data into primitive data and reference data.

Primitive data is:

Each primitive data is provided with a data type, a predefined reserved keyword that indicates what type of data is to be stored. For integer values, there are four data types: byte, short, int, and long. We will focus on using int. For real numbers, there are two data types: float and double. We will focus on using double. For boolean values the data type boolean is used. For character values the data type char is used.

Primitive vs. Reference Data

What if the data isn't a number, boolean, or character? How do we store it then? Data that doesn't fall into these categories are considered reference data. Reference data are used to represent or simulate something that is part of the real-world, like dice or calendar dates. They can also be used to group related data together. Reference data is represented with classes, which are blue prints that specify the data stored and define any behaviors or functions that are included. There are existing classes that can be used or you can create your own classes. There will be opportunities for both throughout these materials.

Some examples of reference data are:

There exists classes that can be used to represent the primitive data types as well.

Activities

Activity 1: Cataloging data

Provide students with a list of different types of data. Have students identify wheter the data can be represented using a primitive data type or if it has to be represented with a reference type. If it is primitive, have them determine which primitive types should be used (int, double, boolean, char).

Some examples can be found in Practice - Classifying Data

Activity 2: Improve Game Data

Have students improve their lists of data for their games (from the discussion above) by adding the data types for each piece of data.

Activity 3: Flash Card Next Day Warm-up

Write descriptions of data on index cards. As students enter the classroom, provide each students with one of the cards. Have them write the data type for their description on the back of the card. Ask them to share with a student next to them and explain why they choose that data type. Does their partner agree or disagree? Is their another data type that might be suitable?