Computer Science - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

Computer Science

Description:

Scope will extend throughout an object's life. Local Variables ... Variable relay important information to the compiler. What kind of object is in cubby ... – PowerPoint PPT presentation

Number of Views:30
Avg rating:3.0/5.0
Slides: 13
Provided by: swea9
Category:
Tags: computer | for | life | relay | science

less

Transcript and Presenter's Notes

Title: Computer Science


1
Computer Science
  • Inside Class Methods

2
Store Values
  • Methods may need to store values
  • Variables and Constants act as containers to hold
    these values

3
Variables
  • Variables are used to hold values
  • Value may change

4
Scope
  • Every variable has a Scope
  • tells where it is visible
  • tells how long variable will hold its value

5
Local Variables
  • Local variables have Scope within the block they
    are created.
  • A block is any code between opening and closing
    braces
  • Variable will remain in scope within nested
    blocks
  • Scope will extend throughout an objects life

6
Local Variables
  • Local Variables are not members of the class
  • Do not mark local variables with access modifiers
    (public, private)
  • Are local to the block in which they are created
  • Not available to every method in the class
  • Sole purpose of a variable is to help the method
    do its job

7
Member Variables
  • Member Variables are members of the class
  • Value is available to any method, or member of
    that class

8
Variables and Memory
  • Computer memory is like a series of cubby holes,
    each having its own address.

9
Variables and the Compiler
  • Variable relay important information to the
    compiler
  • What kind of object is in cubby
  • Size of object
  • Name of object
  • Name is a synonym for the address
  • Name used to access variable

10
Initialization
  • Initialization is the process of declaring a
    variable and assigning it a value
  • Example
  • int x5
  • Int is the data type
  • x is the name
  • 5 is the assigned value

11
Initialize More Than One
  • Using comas, you can declare and initialize more
    than one variable at a time

12
Dont Become Confused
  • Assignment Operator ()
  • Assigns a value
  • X5
  • Equality operator ()
  • Equality operator test whether value is equal to
    x
  • X5
Write a Comment
User Comments (0)
About PowerShow.com