ch03 - Java Programming Fourth Edition Chapter 3 Using...

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

View Full Document Right Arrow Icon
Java Programming Fourth Edition Chapter 3 Using Methods, Classes, and Objects
Background image of page 1

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

View Full DocumentRight Arrow Icon
Java Programming, Fourth Edition 2 Objectives Create methods with no arguments, a single argument, and multiple arguments Create methods that return values Learn about class concepts Create a class Create instance methods in a class
Background image of page 2
Java Programming, Fourth Edition 3 Objectives (continued) Declare objects and use their methods Organize classes Begin to understand how to use constructors
Background image of page 3

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

View Full DocumentRight Arrow Icon
Java Programming, Fourth Edition 4 Creating Methods with Zero, One, and Multiple Arguments Method – Program module – Contains series of statements – Carry out task Execute method – Invoke or call from another method
Background image of page 4
Java Programming, Fourth Edition 5 Creating Methods with Zero, One, and Multiple Arguments (continued) Calling method – Makes method call Called method – Invoked by calling method
Background image of page 5

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

View Full DocumentRight Arrow Icon
Java Programming, Fourth Edition 6 Creating Methods with Zero, One, and Multiple Arguments (continued) Arguments or parameters Return value Method must include: – Declaration • Also called header or definition – Opening curly brace – Body – Closing curly brace
Background image of page 6
Java Programming, Fourth Edition 7 Creating Methods with Zero, One, and Multiple Arguments (continued) Method declaration – Optional access modifiers – Return type for method – Method name – Opening parenthesis – Optional list of method arguments • Separate multiple arguments with commas – Closing parenthesis
Background image of page 7

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

View Full DocumentRight Arrow Icon
Java Programming, Fourth Edition 8 Creating Methods with Zero, One, and Multiple Arguments (continued) Access modifiers – public – private – protected – package Place entire method within class that will use it – Not within any other method
Background image of page 8
Java Programming, Fourth Edition 9 Placement of Methods within a Class
Background image of page 9

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

View Full DocumentRight Arrow Icon
Java Programming, Fourth Edition 10 First Class with main() Calling nameAndAddress()
Background image of page 10
Java Programming, Fourth Edition 11 Creating Methods that Require a Single Argument Arguments – Information sent from outside into method Implementation hiding – Encapsulation of method details within class – Calling method needs to understand only interface to called method Include within method declaration parentheses – Argument type – Local name for argument
Background image of page 11

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

View Full DocumentRight Arrow Icon
Java Programming, Fourth Edition 12 The predictRaise() Method
Background image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/13/2011 for the course 332 351 taught by Professor Staff during the Fall '08 term at Rutgers.

Page1 / 40

ch03 - Java Programming Fourth Edition Chapter 3 Using...

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

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