Using local variable without initialization is an error.

Slides:



Advertisements
Similar presentations
PHP functions What are Functions? A function structure:
Advertisements

Pass by Value. COMP104 Pass by Value / Slide 2 Passing Parameters by Value * A function returns a single result (assuming the function is not a void function)
Chapter 6 Advanced Function Features Pass by Value Pass by Reference Const parameters Overloaded functions.
Local Variables and Scope Benjamin Fein. Variable Scope A variable’s scope consists of all code blocks in which it is visible. A variable is considered.
2.4 Creating and Using Objects. Writing the code for classes of your own will come later. At this time it is possible to understand and correctly write.
PASSING PARAMETERS 1. 2 Parameter Passing (by Value) Parameters Formal Parameters – parameters listed in the header of the function Variables used within.
Definitions declaration abbreviation axiom free types schemas.
Summary of the lecture We discussed –variable scope –instance variable declarations –variable lifetime.
1 Composition A whole-part relationship (e.g. Dog-Tail) Whole and part objects have same lifetime –Whole creates instance of part in its constructor In.
Functions CS 308 – Data Structures. Function Definition Define function header and function body Value-returning functions return-data-type function-name(parameter.
Evan Korth New York University Computer Science I Classes and Objects Professor: Evan Korth New York University.
© The McGraw-Hill Companies, 2006 Chapter 5 Arrays.
Launching a Report from Forms Programming the Forms Trigger.
Linear Programming General Form of an LP Model. Linear Programming General Form of an LP Model where the c’s, a’s and b’s are constants determined from.
Chapter 7 Methods: A Deeper Look Visual C# 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
Fall 2005CSE 115/503 Introduction to Computer Science I1 Composition details Recall, composition involves 3 things: –Declaration of instance variable of.
The different kinds of variables in a Java program.
INTRODUCTION TO EMBEDDED SYSTEMS INTERFACING TO THE FREESCALE 9S12 Power Point Presentation Local Variables and Parameter Passing 8-1.
1 Chapter 3 and 6– Classes, Objects and Methods Object-Oriented Programming Concepts – Read it from Java TutorialJava Tutorial Definition: A class is a.
Dale Roberts Object Oriented Programming using Java - Enumerations Dale Roberts, Lecturer Computer Science, IUPUI Department.
ECE122 Feb. 22, Any question on Vehicle sample code?
 Classes in c++ Presentation Topic  A collection of objects with same properties and functions is known as class. A class is used to define the characteristics.
Built-In and user-Defined functions Software Design Concepts Lecture IV Dr. Sothy Vignarajah.
SEEM3460 Tutorial Java Keyword – static. static Variables class XY { static int x; // class variable int y; // instance variable } XY xy1 = new XY();
ICBT  Basura Ramanayaka  Eshani werapitiya  Hasitha Dananjaya.
Graphics Tools and Parameters Chris Nevison Barbara Wells.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
ROBOTC for IFI Timothy Friez Class #4 2/5/08. Agenda for Tonight Timers Functions Your Questions.
Introduction to Computers and Programming Class 24 Structures (structs) Professor Avi Rosenfeld.
Array Size Arrays use static allocation of space. That is, when the array is created, we must specify the size of the array, e.g., int[] grades = new int[100];
AP Java Ch. 4 Review Question 1  Java methods can return only primitive types (int, double, boolean, etc).
Function PrototypetMyn1 Function Prototype We can declare a function before we use or define it by means of a function prototype. A function prototype.
Question of the Day  Move one matchstick to produce a square.
COMP 110 More about classes Luv Kohli October 3, 2008 MWF 2-2:50 pm Sitterson 014.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI N305 Pointers Call-by-Reference.
INTRODUCTION TO CLASSES & OBJECTS CREATING CLASSES USING C#
Chapter 5 Arrays F Introducing Arrays F Declaring Array Variables, Creating Arrays, and Initializing Arrays F Passing Arrays to Methods F Copying Arrays.
TK1924 Program Design & Problem Solving Session 2011/2012
Haidong Xue Summer 2011, at GSU
More About Objects and Methods
Function There are two types of Function User Defined Function
FIGURE 9-5 Integer Constants and Variables
CSC 253 Lecture 8.
آشنايی با اصول و پايه های يک آزمايش
Const in Classes CSCE 121 J. Michael Moore.
CSC 253 Lecture 8.
Chapter 4 (part 2).
Variables and Their scope
Sampling Distribution
Sampling Distribution
Anatomy of a Function Part 3
when need to keep permanently
Pointers Call-by-Reference CSCI 230
Reference Parameters.
Java Programming Course
Pointers.
Topics discussed in this section:
CS2011 Introduction to Programming I Arrays (I)
Programs and Classes A program is made up from classes
Which best describes the relationship between classes and objects?
1.4 ทบทวน JAVA OO Programming Concepts Declaring and Creating Objects
Notes Over 2.4 Writing an Equation Given the Slope and y-intercept
Agenda Warmup Lesson 2.2 (parameters, etc)
Topics discussed in this section:
Model Direct Variation
Chapter (3) - Procedures
Types of Errors And Error Analysis.
Methods Scope How are names handled?
Parameters and Arguments
Scope Rules.
Presentation transcript:

Using local variable without initialization is an error

After Initialization you can use a local variable

A variable declared in one method is local variable to it and cannot be used in another method

An instance variable can be used by any method of the class

A parameter of one method cannot be used in another method without passing to that.