Lecture_02 - ENGR 2200U UOIT/FEAS Fall 2007 ENGR 2710U OO...

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

View Full Document Right Arrow Icon
ENGR 2200U UOIT/FEAS Fall 2007 © Mike Eklund ENGR 2710U OO Programming and Design 1 Using Objects Professor Saman Kumarawadu ENGR 2710U Fall 2010 – Saman Kumarawadu ENGR 2710U OO Programming and Design Objectives • To learn about variables • To understand the concepts of classes and objects • To be able to call methods • To realize the difference between objects and object references ENGR 2710U Fall 2010 – Saman Kumarawadu
Background image of page 1

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

View Full DocumentRight Arrow Icon
ENGR 2200U UOIT/FEAS Fall 2007 © Mike Eklund ENGR 2710U OO Programming and Design Number Types • Integers: short, int, long 13 • Floating point numbers: float, double 1.3 0.00013 • Numbers are not objects; number types are primitive types ENGR 2710U OO Programming and Design Basic Data Types • Every value has type. • Types boolean either true or false char 16 bit Unicode 1.1 byte 8-bit integer (signed) short 16-bit integer (signed) int 32-bit integer (signed) long 64-bit integer (singed) float 32-bit floating point (IEEE 754-1985) double 64-bit floating point (IEEE 754-1985) String (class for manipulating strings) Java uses Unicode to represent characters internally
Background image of page 2
ENGR 2200U UOIT/FEAS Fall 2007 © Mike Eklund ENGR 2710U OO Programming and Design Arithmetic Operations • Operators: + - * 10 + n n - 1 10 * n // 10 × n • As in mathematics, the * operator binds more strongly than the + operator x + y * 2 // means the sum of x and y * 2 (x + y) * 2 // multiplies the sum of x and y with 2 ENGR 2710U OO Programming and Design Self Test 1. Which number type would you use for storing the area of a circle? 2. Why is the expression 13.println() an error? 3. Write an expression to compute the average of the values x and y .
Background image of page 3

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

View Full DocumentRight Arrow Icon
ENGR 2200U UOIT/FEAS Fall 2007 © Mike Eklund ENGR 2710U OO Programming and Design Answers 1.double 2. An int is not an object, and you cannot call a method on it 3.(x + y) * 0.5 ENGR 2710U OO Programming and Design Types and Variables • Variable is the storage location: has a type, name and a content • Variable declaration examples: String greeting = "Hello, World!"; PrintStream printer = System.out; int luckyNumber = 13; • Variables • Store values • Can be used in place of the objects they store
Background image of page 4
ENGR 2200U UOIT/FEAS Fall 2007 © Mike Eklund ENGR 2710U OO Programming and Design Declare Variables What type should you use? What name should you give?
Background image of page 5

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

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

Page1 / 17

Lecture_02 - ENGR 2200U UOIT/FEAS Fall 2007 ENGR 2710U OO...

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

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