Chapter 4 Procedural Methods. Learning Java through Alice © Daly and Wrigley Objectives Identify classes, objects, and methods. Identify the difference.

Slides:



Advertisements
Similar presentations
Classes & Objects INTRODUCTION : This chapter introduces classes ; explains data hiding, abstraction & encapsulation and shows how a class implements these.
Advertisements

Chapter 2: Using Objects Part 1. To learn about variables To understand the concepts of classes and objects To be able to call methods To learn about.
Chapter 7 User-Defined Methods. Chapter Objectives  Understand how methods are used in Java programming  Learn about standard (predefined) methods and.
IT151: Introduction to Programming
1 Chapter 7 User-Defined Methods Java Programming from Thomson Course Tech, adopted by kcluk.
Chapter 2 storing numbers and creating objects Pages in Horstmann.
Datalogi A 2: 15/9. Java Slides based on Horstmann chapter 2&3 Objects and classes Import, methods, references Implementing a class.
Chapter 2  Using Objects 1 Chapter 2 Using Objects.
LESSON 4 - Variables JAVA PROGRAMMING. Variables Variable is a named storage location that stores data and the value of the data may change while the.
Chapter 2 types, variables, methods Pages Horstmann.
Moving To Code 3 More on the Problem-Solving Process §The final step in the problem-solving process is to evaluate and modify (if necessary) the program.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
Methods Chapter 6. 2 Program Modules in Java What we call "functions" in C++ are called "methods" in Java Purpose Reuse code Modularize the program This.
1 Identifiers  Identifiers are the words a programmer uses in a program  An identifier can be made up of letters, digits, the underscore character (
Tutorial 2 Variables and Objects. Working with Variables and Objects Variables (or identifiers) –Values stored in computer memory locations –Value can.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
The Java Programming Language
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 3 Simple.
JAVA Tokens. Introduction A token is an individual element in a program. More than one token can appear in a single line separated by white spaces.
Classes CS 21a: Introduction to Computing I First Semester,
1. 2 Reference... Student stu; Reference of Student stu When the reference is created it points to a null value. Before access the reference, objects.
Chapter 2: Java Fundamentals
Week 2 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Chapter 2 Using Objects. Types A type defines a set of values and the operations that can be carried out on the values Examples: 13 has type int "Hello,
BASICS CONCEPTS OF ‘C’.  C Character Set C Character Set  Tokens in C Tokens in C  Constants Constants  Variables Variables  Global Variables Global.
CS346 Javascript -3 Module 3 JavaScript Variables.
1 Principles of Computer Science I Prof. Nadeem Abdul Hamid CSC 120 – Fall 2005 Lecture Unit 2 - Using Objects.
COM S 207 Method Instructor: Ying Cai Department of Computer Science Iowa State University
Classes: user-defined types. Organizing method with a class A class is used to organize methods * Methods that compute Mathematical functions * The Scanner.
Chapter 2 Variables.
Java Class Structure. Class Structure package declaration import statements class declaration class (static) variable declarations* instance variable.
User Defined Methods Methods are used to divide complicated programs into manageable pieces. There are predefined methods (methods that are already provided.
Java Classes Chapter 1. 2 Chapter Contents Objects and Classes Using Methods in a Java Class References and Aliases Arguments and Parameters Defining.
Chapter 2 Using Objects. Chapter Goals To learn about variables To understand the concepts of classes and objects To be able to call methods To be able.
Values, Types, and Variables. Values Data Information Numbers Text Pretty much anything.
Chapter 5. Outline Some Exercises in C++ Names Variables Scope Lifetime.
Methods Chapter 6. 2 Program Modules in Java What we call "functions" in C++ are called "___________________" in Java Purpose –Reuse code –Modularize.
Chapter 2. Variable and Data type
© 2006 Pearson Addison-Wesley. All rights reserved 1-1 Chapter 1 Review of Java Fundamentals.
Methods.
MAHENDRAN. Session Objectives Session Objectives  Discuss the Origin of C  Features of C  Characteristics of C  Current Uses of C  “C” Programming.
Chapter 5 Arrays F Introducing Arrays F Declaring Array Variables, Creating Arrays, and Initializing Arrays F Passing Arrays to Methods F Copying Arrays.
Chapter 3 Using Variables, Constants, Formatting Mrs. UlshaferSept
Methods Matthew Harrison. Overview ● There are five main aspects of methods... ● 1) Modifiers – public, private ● 2) Method Name ● 3) Parameters ● 4)
Functions + Overloading + Scope
Chapter 7 User-Defined Methods.
Working with Java.
Chapter 2 Elementary Programming
Methods Chapter 6.
Revision Lecture
University of Central Florida COP 3330 Object Oriented Programming
Data types and variables
' C ' PROGRAMMING SRM-MCA.
CMSC 104, Section 4 Richard Chang
Chapter 4 Procedural Methods.
Method Mark and Lyubo.
Chapter 3 Simple Functions
Chapter 2 Using Objects.
Introduction to Java Programming
Unit-1 Introduction to Java
Chapter 2 Variables.
Chapter 2: Java Fundamentals
1.2 Function and Class Names
Chapter 7 Procedural Methods.
METHODS, CLASSES, AND OBJECTS A FIRST LOOK
Anatomy of a Java Program
Classes CS 21a: Introduction to Computing I
Chap 2. Identifiers, Keywords, and Types
Use a variable to store a value that you want to use at a later time
Corresponds with Chapter 5
Presentation transcript:

Chapter 4 Procedural Methods

Learning Java through Alice © Daly and Wrigley Objectives Identify classes, objects, and methods. Identify the difference between a procedure method and a function method. Differentiate between parameters and arguments. Write procedure methods with parameters. Explain the purpose of the Java API. 2

Learning Java through Alice © Daly and Wrigley Procedure Methods A procedural method is a coordinated sequence of instructions that will be carried out when requested. 3

Learning Java through Alice © Daly and Wrigley Java Programming Interface (API) 4

Learning Java through Alice © Daly and Wrigley Method Syntax The syntax for a method is: modifier static returntype methodname ( list of parameters ) {.... statements to do inside of method } Modifiers determine the scope of a method. ▫public means that the method is available in the current class (program) and other classes. ▫private means that you intend to use the variable or method in the current program. Return Type ▫Data type: int, double, float, etc. ▫No return type: void 5

Learning Java through Alice © Daly and Wrigley Naming Methods Consists of letters, digits, underscores (_) or $ (no spaces allowed). First character can't be a digit. Cannot be keywords. Stylistic Rule: all method names begin with a lowercase letter with all other words beginning with uppercase letter such as displayIt, sumNumbers, etc. Method names should be meaningful. 6

Learning Java through Alice © Daly and Wrigley Methods with No Parameters 7

Learning Java through Alice © Daly and Wrigley Methods with No Parameters 8

Learning Java through Alice © Daly and Wrigley Methods with Some Parameters 9

Learning Java through Alice © Daly and Wrigley Methods with Some Parameters 10

Learning Java through Alice © Daly and Wrigley Object Methods 11

Learning Java through Alice © Daly and Wrigley Static Methods 12