lecture-22 - Java – Numerical Data 1 Object Oriented...

Info iconThis preview shows pages 1–14. Sign up to view the full content.

View Full Document Right Arrow Icon
Object Oriented Programming Numerical Data R.B. Lenin Winter - 2006 DA-IICT 1 Java – Numerical Data
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Object Oriented Programming Numerical Data R.B. Lenin Winter - 2006 DA-IICT 2 Variables • There are six numerical data types in Java: –by te – short –in t – long – float – double • Data types byte, short, int , and long are for integers. Float and
Background image of page 2
Object Oriented Programming Numerical Data R.B. Lenin Winter - 2006 DA-IICT 3 Variables • The (only) difference between a variable for numbers and a variable for objects is the contents in the memory locations. – For numbers, a variable contains the numerical value itself. – For objects, a variable contains an address where the object is stored.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Object Oriented Programming Numerical Data R.B. Lenin Winter - 2006 DA-IICT 4 A diagram showing how two memory locations (variables) are declared, and values are assigned to them.
Background image of page 4
Object Oriented Programming Numerical Data R.B. Lenin Winter - 2006 DA-IICT 5 Difference between variable creation and object creation
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Object Oriented Programming Numerical Data R.B. Lenin Winter - 2006 DA-IICT 6
Background image of page 6
Object Oriented Programming Numerical Data R.B. Lenin Winter - 2006 DA-IICT 7 Variables • We use the new command to create an object. • Objects are called reference data types – the contents are addresses that refer to memory locations where the objects are actually stored. • Numerical data are called primitive data types – For example, we don’t create an integer, because the space to store the value is already allocated at the time an integer variable is declared.
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Object Oriented Programming Numerical Data R.B. Lenin Winter - 2006 DA-IICT 8 An effect of assigning the content of one variable to another.
Background image of page 8
Object Oriented Programming Numerical Data R.B. Lenin Winter - 2006 DA-IICT 9
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Object Oriented Programming Numerical Data R.B. Lenin Winter - 2006 DA-IICT 10 Arithmetic Expressions
Background image of page 10
Object Oriented Programming Numerical Data R.B. Lenin Winter - 2006 DA-IICT 11 Arithmetic Expressions • Precedence rules for arithmetic operators and parentheses
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Object Oriented Programming Numerical Data R.B. Lenin Winter - 2006 DA-IICT 12 Arithmetic Expressions Rules for arithmetic promotion
Background image of page 12
Object Oriented Programming Numerical Data R.B. Lenin Winter - 2006 DA-IICT 13 Arithmetic Expressions • Type cast Operator – explicit conversion – If x is an int variable, then x/3 will be truncated to an integer. But
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 14
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 33

lecture-22 - Java – Numerical Data 1 Object Oriented...

This preview shows document pages 1 - 14. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online