03Reference and primitive data types

03Reference and primitive data types - Preamble Data types...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: Preamble Data types Call-by-value Scope ITI 1121. Introduction to Computing II Marcel Turcotte (with contributions from R. Holte) School of Information Technology and Engineering University of Ottawa Version of January 10, 2011 Please dont print these lecture notes unless you really need to! Marcel Turcotte ITI 1121. Introduction to Computing II Preamble Data types Call-by-value Scope Review Objectives: 1. Discussing several concepts related to data types 2. Understanding the implications of the differences between primitive and reference types 3. Reviewing call-by-value 4. Understanding the concept of scope Lectures: I Pages 597631 of E. Koffman and P. Wolfgang. Marcel Turcotte ITI 1121. Introduction to Computing II Preamble Data types Call-by-value Scope Plan 1. What are variables and data types 2. Primitive vs reference 3. Comparison operators (primitive vs reference) 4. Auto-boxing/auto-unboxing; 5. Passing parameters 6. Scope 7. Memory management Marcel Turcotte ITI 1121. Introduction to Computing II Preamble Data types Call-by-value Scope Memory representation Primitive vs reference types Comparison operators Variables What is a variable? I A variable is a place in memory, to hold a value , which we refer to with help of a label 33 (i) 0,000,123,456 ... ... 4,294,967,296 0,000,000,000 0,000,123,457 0,000,123,455 byte i = 33; Marcel Turcotte ITI 1121. Introduction to Computing II Preamble Data types Call-by-value Scope Memory representation Primitive vs reference types Comparison operators Variables I will be using Greek letters to designate memory locations (addresses) since in Java we dont know the location of objects and should not care! 33 (i) ... ... + 1 1 byte i = 33; Marcel Turcotte ITI 1121. Introduction to Computing II Preamble Data types Call-by-value Scope Memory representation Primitive vs reference types Comparison operators Data types What are data types for? I Yes, it tells the compiler how much memory to allocate: double formula ; // 8 bytes char c ; // 2 bytes I But it also? It gives information about the meaning (semantic) of the data: which operations are allowed , which data are compatible. Hence the following statement, c = f l a g * formula ; will produce an error at compile time; data types are therefore also useful to help detect errors in programs early on. Marcel Turcotte ITI 1121. Introduction to Computing II Preamble Data types Call-by-value Scope Memory representation Primitive vs reference types Comparison operators Data types (contd) I To be more precise, there are concrete data types and abstract data types I Concrete data types specify both, the allowed operations and the representation of the data I Abstract Data Types (ADTs) specify only the allowed operations Marcel Turcotte ITI 1121. Introduction to Computing II Preamble Data types Call-by-value Scope Memory representation Primitive vs reference types Comparison operators Data Types in Java In Java, we have primitive and reference data types:...
View Full Document

This note was uploaded on 03/02/2012 for the course ITI 1121 taught by Professor Samaan during the Winter '10 term at University of Ottawa.

Page1 / 81

03Reference and primitive data types - Preamble Data types...

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

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