Data type, Type Casting,Constants. DATA TYPES IN JAVA.

Slides:



Advertisements
Similar presentations
Types, Variables and Operators Computer Engineering Department Java Course Asst. Prof. Dr. Ahmet Sayar Kocaeli University - Fall 2013.
Advertisements

Data Types in Java Data is the information that a program has to work with. Data is of different types. The type of a piece of data tells Java what can.
Constants and Variables  Memory cells used in program  Called constants and variables  Identifiers for constants and variables should be declared before.
CS102 Data Types in Java CS 102 Java’s Central Casting.
Program Elements We can now examine the core elements of programming (as implemented in Java) We focuse on: data types variable declaration and use, constants.
CS 178: Programming with Multimedia Objects Aditya P. Mathur Professor of Computer Sciences Purdue University, West Lafayette Sept 20, 2004 Last update:
ECE122 L3: Expression Evaluation February 6, 2007 ECE 122 Engineering Problem Solving with Java Lecture 3 Expression Evaluation and Program Interaction.
PZ04A Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ04A - Scalar and composite data Programming Language.
CSci 142 Data and Expressions. 2  Topics  Strings  Primitive data types  Using variables and constants  Expressions and operator precedence  Data.
Agenda Review User input Scanner Strong type checking Other flow-control structures switch break & continue Strings Arrays 2.
Copyright © 2003 Pearson Education, Inc. Slide 2-1 Problem Solving with Java™ Second Edition Elliot Koffman and Ursula Wolz Copyright © 2003 Pearson Education,
 Value, Variable and Data Type  Type Conversion  Arithmetic Expression Evaluation  Scope of variable.
The Data Element. 2 Data type: A description of the set of values and the basic set of operations that can be applied to values of the type. Strong typing:
Java Primitives The Smallest Building Blocks of the Language (corresponds with Chapter 2)
Primitive Data Types and Operations Identifiers, Variables, and Constants Primitive Data Types Byte, short, int, long, float, double, char, boolean Casting.
Chapter 2 Primitive Data Types and Operations F Introduce Programming with an Example  The MyInput class F Identifiers, Variables, and Constants F Primitive.
1 Chapter 2 Primitive Data Types and Operations F Introduce Programming with an Example  The MyInput class F Identifiers, Variables, and Constants F Primitive.
SOFTWARE TECHNOLOGY - I CONSTANTS VARIABLES DATA TYPES.
1 Do you have a CS account? Primitive types –“ building blocks ” for more complicated types Java is strongly typed –All variables in a Java program must.
Lecture 2 Object Oriented Programming Basics of Java Language MBY.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 3A Integral Data (Concepts)
Outline Character Strings Variables and Assignment Primitive Data Types Expressions Data Conversion Interactive Programs Graphics Applets Drawing Shapes.
Lec 6 Data types. Variable: Its data object that is defined and named by the programmer explicitly in a program. Data Types: It’s a class of Dos together.
Java Simple Types CSIS 3701: Advanced Object Oriented Programming.
Primitive Variables.
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
1 Operations Making Things Happen (Chap. 3) Expressions.
Java Overview. Comments in a Java Program Comments can be single line comments like C++ Example: //This is a Java Comment Comments can be spread over.
The character data type char. Character type char is used to represent alpha-numerical information (characters) inside the computer uses 2 bytes of memory.
Programming with Visual C++: Concepts and Projects Chapter 3A: Integral Data (Concepts)
Java Programming, Second Edition Chapter Two Using Data Within a Program.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
COM S 207 Literal, Operator, and Expression Instructor: Ying Cai Department of Computer Science Iowa State University
Data Tonga Institute of Higher Education. Variables Programs need to remember values.  Example: A program that keeps track of sales needs to remember.
1 MATERI PENDUKUNG TIPE DATA Matakuliah: M0074/PROGRAMMING II Tahun: 2005 Versi: 1/0.
 Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. 
DATA TYPES, VARIABLES AND CONSTANTS. LEARNING OBJECTIVES  Be able to identify and explain the difference between data and information  Be able to identify,
LESSON 5 – Assignment Statements JAVA PROGRAMMING.
A data type in a programming language is a set of data with values having predefined characteristics.data The language usually specifies:  the range.
1 1 Chapter 2 Elementary Programming. 2 2 Motivations In the preceding chapter, you learned how to create, compile, and run a Java program. Starting from.
JAVA Practical Unary operators 2. Using Reals 3. Conversions 4. Type Casting 5. Scope 6. Constants.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
1 2. Program Construction in Java. 01 Java basics.
1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,
Basic Data Types อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา Chapter 4.
1 Scalar and composite data Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Scalar and composite data Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
CSE 110: Programming Language I Matin Saad Abdullah UB 1222.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
ISBN Chapter 7 Expressions and Assignments Statements.
April 13, 1998CS102-02Lecture 3-1 Data Types in Java CS Lecture 3-1 Java’s Central Casting.
Relational Operator and Operations
Primitive/Reference Types and Value Semantics
Object Oriented Programming
Multiple variables can be created in one declaration
Primitive and Reference Data Values
Type Conversion, Constants, and the String Object
Chapter 2.
IDENTIFIERS CSC 111.
Primitive and Reference Data Values
Type Conversion, Constants, and the String Object
Unit-2 Objects and Classes
Lecture 8.
Wrapper Classes The java.lang package contains wrapper classes that correspond to each primitive type: Primitive Type Wrapper Class byte Byte short Short.
Numerical Data Types.
Java Basics Data Types in Java.
Java’s Central Casting
Type Conversion It is a procedure of converting one data type values into another data type In C programming language we are having two types of type conversion.
Chapter 2 Primitive Data Types and Operations
Presentation transcript:

Data type, Type Casting,Constants

DATA TYPES IN JAVA

Data types in java Every variable declared in a Java program is having the data type. Data type specifies the size and type of values that a variable can have. Java has a rich set of data types.

Integer Data Type

Real Data Type

Character & Boolean Data Type Character :In order to store single character constant in a variable, character data type is used. - minimum value is ‘\u000’=0 - maximum value is ‘\uffff’=65535 Boolean :Boolean data type is used to store two different values. But,values stored inside the boolean type will only be true and false.

Type Casting

What is type casting? Changing a value from one data type to another data type is known as data type conversion i.e. assigning a value of one type of a variable of another type is known as type casting. Types of type casting: 1.Widening Type Casting (Implicit) 2.Narrowing Type Casting ( Explicit)

Widening Type Casting (Implicit) If a value of lower size data type converted to a value of higher size data type without loss of information is Implicit casting.

Narrowing Type Casting ( Explicit) If a value of higher size data type converted to a value of lower size data type without loss of information is Implicit casting.

MSBTE Question Bank: Q1.Write all primitive data type available in java with their storage sizes in bytes.(w-9, s-12).Write all primitive data type available in java with their storage sizes in bytes Q2. List different data types in java.(s-10). List different data types in java Q3. Give all the primitive data types available in java with their strorage size in bytes. (s-13) Q4. Explain ‘type casting ‘ with example.(s-11)Explain ‘type casting ‘ with example Q5. What do you mean by type casting ?when is it needed?(w-12). What do you mean by type casting ?when is it needed?(