OOP - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

OOP

Description:

So, for example, the Dog class has a bark() method. The code for the bark() method defines exactly how a bark happens (e.g., by ... – PowerPoint PPT presentation

Number of Views:44
Avg rating:3.0/5.0
Slides: 13
Provided by: iLL58
Category:
Tags: oop | barking

less

Transcript and Presenter's Notes

Title: OOP


1
OOP JAVA
2
HelloWorld.java
  • / The HelloWorld class is an application that
    displays "Hello World!" to the standard output.
    /
  • public class HelloWorld
  • // Display "Hello World!"
  • public static void main(String args)
    System.out.println("Hello World!")
  • Compile C\gt javac HelloWorld.java
  • Create java bytecode HelloWorld.class
  • Run C\gt java HelloWorld

3
HelloWorld.java (Applet)
  • webpage.html
  • HelloWorldApplet.java

4
Definitions of OOP
  •  Class
  • A class defines the abstract characteristics of a
    thing (object), including the thing's
    characteristics (its attributes or properties)
    and the things it can do (its behaviors or
    methods or features).
  • For example, the class Dog would consist of
    traits shared by all dogs, for example breed, fur
    color, and the ability to bark.

5
Definitions of OOP
  • Object
  • The class of Dog defines all possible dogs by
    listing the characteristics that they can have
    the object Lassie is one particular dog, with
    particular versions of the characteristics. A Dog
    has fur Lassie has brown-and-white fur.
  • In programmer jargon, the object Lassie is an
    instance of the Dog class. The set of values of
    the attributes of a particular object is called
    its state.

6
Definitions of OOP
  • Method
  • An object's abilities. Lassie, being a Dog, has
    the ability to bark. So bark() is one of Lassie's
    methods. She may have other methods as well, for
    example sit() or eat(). Within the program, using
    a method should only affect one particular
    object all Dogs can bark, but you need one
    particular dog to do the barking.

7
Definitions of OOP
  • Message passing
  • "The process by which an object sends data to
    another object or asks the other object to invoke
    a method."

8
Definitions of OOP
  • Inheritance

9
Definitions of OOP
  • Encapsulation 
  • Conceals the exact details of how a particular
    class works from objects that use its code or
    send messages to it. So, for example, the Dog
    class has a bark() method. The code for the
    bark() method defines exactly how a bark happens
    (e.g., by inhale() and then exhale(), at a
    particular pitch and volume).

10
Definitions of OOP
  • Polymorphism
  • is the ability of behavior to vary based on the
    conditions in which the behavior is invoked, that
    is, two or more methods, as well as operators
    (such as , -, , among others) can fit to many
    different conditions.
  • Ex. method signatures would be, respectively,
    very similar to add(int a, int b) and add(String
    a, String b). This is an example of Parametric
    Polymorphism. The returned type and used
    modifiers, of course, depend on the programmer
    interests and intentions.

11
JAVA basics
  • http//leepoint.net/notes-java/index.html

12
Javas Scope
  • Scope is a term used to define where a variable
    is defined.
  • EX.
  • Function eat()
  • int money100
  • Print money
  • Function buy()
  • int money200
  • Print money
  • main()
  • int money0
  • eat()
  • buy()
  • Print money
Write a Comment
User Comments (0)
About PowerShow.com