You are on page 1of 16

MIT 605 Advance Programming

Reporter: Rally T. Cautiverio

Copyright 2013 Accenture All Rights Reserved.

Topic of the Report

Java Programming Data Types

Copyright 2013 Accenture All Rights Reserved.

Contents

Data Type Definition


Identifier Definition
Primitive Data Types
Reference Data Types

Copyright 2013 Accenture All Rights Reserved.

Data Type Definition


What is Data Type?
Specifies the type of data to be stored in an
identifier.
In computer programming, a data type (or
datatype) is a classification identifying one of various
types of data

Copyright 2013 Accenture All Rights Reserved.

Identifier Definition
What is identifier?
The name given by the
constant/variable, function, or class.

programmer

to

A location in your computers memory in which you


can store a value and from which you can retrieve that
value. (From a programmers point of view.)

Copyright 2013 Accenture All Rights Reserved.

Classification of Java Data Types


Primitive Data Type
basic type provided by a programming language as a
basic building block.
also known as built-in type.
Reference Data Type
programmer-defined data type.
is a variable that can contain the reference or an
address of dynamically created object. These type of data
type are not predefined like primitive data type.
Copyright 2013 Accenture All Rights Reserved.

Primitive Data Types


1. Logical Data Type
a. boolean

2. Integer Types
a.
b.
c.
d.

byte
short
int
long*

-128 to 127 (8 bit)


-32,768 to 32,767 (16 bit)
-2,147,483,648 to 2,147,483,647 (32 bit)
-9,223,372,036,854,775,808 to
9,223,372,036,854,775,807 (64 bit)

3. Floating Point
a. float* 1.401298 x 10-45 to 3.402823 x 1038 (32 bit)
b. double 4.940656 x 10-324 to 1.797693 x 10308 (64 bit)
Copyright 2013 Accenture All Rights Reserved.

Contd.
4. Char Data Type
a. char

0 to 65,535 (16 bit)

Copyright 2013 Accenture All Rights Reserved.

Reference Data Type


A. Array Type
An array is a list of identifiers, which all have the same data
types and same name.
Points to an array instance.
B. Class Type
Points to an object or a class instance.
C. Interface Type
Points to an object and a method, which is implemented to
the corresponding interface
Copyright 2013 Accenture All Rights Reserved.

Examples:
import java.io.*;
public class JavaDataTypes {
public static void main(String[] args) throws Exception {
byte b1 = 100; // byte
System.out.println(Variable b1: +b1);
short s1 = 1500; // short
System.out.println(Variable s1: +s1);
float f = 10.4f; // float
System.out.println(Variable f: +f);
double d = 1232.44; // double
System.out.println(Variable d: +d);
char ch1 = a; // character
char ch2 = 65; // ASCII code for A
System.out.println(Value of ch1: +ch1);
System.out.println(Value of ch2: +ch2);
}
}
Copyright 2013 Accenture All Rights Reserved.

10

Examples:

(Contd.)

import java.io.*;
import java.util.Scanner;
public class JavaDataTypes {
public static void main(String[] args) {
Scanner abc = new Scanner(System.in);
System.out.println(abc.nextLine());
}
}

Copyright 2013 Accenture All Rights Reserved.

11

Examples:

(Contd.)

import java.io.*;
import java.util.Scanner;
public class JavaDataTypes {
public static void main(String[] args) {
Scanner abc = new Scanner(System.in);
double fnum, snum, answer;
System.out.println(Enter first number: );
fnum = abc.nextDouble();
System.out.println(Enter second number: );
snum = abc.nextDouble();
answer = fnum + snum;
System.out.println(answer);
}
}
Copyright 2013 Accenture All Rights Reserved.

12

Keywords Definition
What is keyword?
reserved words used by a programming language.

Copyright 2013 Accenture All Rights Reserved.

13

Keywords Table
abstract

do

implement

private

throw

boolean

double

import

protected

throws

break

else

instanceof

public

transient

byte

extends

int

return

true

case

false

interface

short

try

catch

final

long

static

void

char

finally

native

super

volatile

class

float

new

switch

while

continue

for

null

synchronized

this

default

if

package

Copyright 2006 Accenture All Rights Reserved.

14

Facilitators Point of View


I can not teach anybody anything;
I can only make them think.
Socrates

Copyright 2013 Accenture All Rights Reserved.

21

Questions and Comments

Copyright 2013 Accenture All Rights Reserved.

22

You might also like