Chapter2

Chapter2 - Java Software Solutions. Chapter 2: Objects and...

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

View Full Document Right Arrow Icon
Java – Software Solutions…. Chapter 2: Objects and Primitive 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
2 Objects and Primitive Data Now we can explore some more fundamental programming concepts Chapter 2 focuses on: predefined objects primitive data the declaration and use of variables expressions and operator precedence creating and using objects class libraries
Background image of page 2
3 Introductory Notions Need ability to create and use objects. Provide ‘services’ Objects are fundamental to writing programs in an OOP language. Objects ‘do’ all the things we want: Manipulate strings Make computations Do input/output Draw shapes…
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Introduction to Objects An object represents something with which we can interact in a program An object provides a collection of services that we can tell it to perform for us The services are defined by methods in a class that defines the object A class represents a concept, and an object represents the embodiment of a class A class can be used to create multiple objects
Background image of page 4
5 Introduction to Objects Objects also manage data Maybe primitive; maybe complex (like integers, floats…) Most complex data consists if primitive data… A data type defines a set of values and operations that can be performed on those values. Think: integers ; +, -, *, /, no division by zero… Objects is defined by a class – an abstraction; a generalization. Objects are ‘instances’ of a class. Operations (methods ) are defined by methods in the class. Methods – a collection of programming statements with a given name that perform some kind of operation
Background image of page 5

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

View Full DocumentRight Arrow Icon
6 Objects and Classes Bank Account A class (the concept) Class = BankAccount John’s Bank Account Balance: $5,257 An object (a realization) (an ‘instantiation’) Bill’s Bank Account Balance: $1,245,069 Mary’s Bank Account Balance: $16,833 Multiple objects from the same class . Has attributes (data) . Has methods (operations) Classes ‘encapsulate’ attributes and methods.
Background image of page 6
7 Inheritance One class can be used to derive another via inheritance Classes can be organized into inheritance hierarchies Bank  Account Account Charge  Account Savings  Account Checking  Account Think: Gender Men Women Mothers non-Mothers
Background image of page 7

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

View Full DocumentRight Arrow Icon
8 Using Objects The System.out object represents a destination to which we can send output In the Lincoln program, we invoked the println method of the System.out object: System.out.println ("Whatever you are, be a good one."); object method information provided to the method (parameters) Notice the ‘notation’ for referencing the method: object.method We are SENDING A MESSAGE to the object, System.out. We are requesting that the object perform a ‘service’ for us by invoking.
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/26/2011 for the course COP 2551 taught by Professor Roggio,r during the Summer '08 term at UNF.

Page1 / 63

Chapter2 - Java Software Solutions. Chapter 2: Objects and...

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