• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Chapter2 bag2

Chapter2 bag2






Total Views
Views on SlideShare
Embed Views



1 Embed 47

http://diakbar.wordpress.com 47



Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

    Chapter2 bag2 Chapter2 bag2 Presentation Transcript

    • 2.1 Introduction to Object- Oriented Programming
    • 2.1.1 Procedural versus OOP languages • Procedural programming involves creating a sequence of instructions • OOP uses a collection of interacting objects • Functions are logically grouped, making enhancements easy • OOP can model human problem- solving
    • 2.1.2 Basic Java terminology Object. contains data and instructions Class. blueprint for an object Attribute. describe the state of objects Data Type. describes what kind of information a certain attribute is Behavior. describe what objects can do Method. a set of instructions Inheritance. Some objects derive attributes and behaviors from other objects Encapsulation. Combining data and methods together
    • 2.2 What are Objects? 2.2.1 Introduction to objects • Anything tangible or abstract that is relevent • Objects can have attributes and behaviors • Attributes describe the object • Behaviors describe what the object can do
    • 2.2.2 Classification of objects • User Interface objects – Objects that the user interacts directly with • Operating environment objects – Provide services to other components • Task Related objects – Documents, multimedia, problem domain
    • 2.2.3 Objects - identifying, defining, creating and operating on • Identifying – Requires needs assessment • Defining – Classification, relationships, operations. The class keyword • Creating – The constructor and the new keyword • Operating – Using an object’s methods
    • 2.2.7 Encapsulation • To hide the details, package together • Access modifiers – public, private and protected
    • 2.2.8 Object relationships • Association – Objects know about each other • Whole-part – Existance of an object relies on another • Inheritance – Attributes & behaviors can be inherited
    • 2.2.9 Inheritance
    • 2.2.10 Object mutability and destruction • Some object attributes should be immutable, or unchangable • To make an item immutable, use the final keyword • The JVM automatically releases memory when objects are no longer required • The garbage collector will reclaim memory by objects that are no longer referenced • Garage collection is not controllable
    • 2.3.1 Modeling languages and symbols • Unified Modeling Language (UML) standardizes symbols & terminology for diagramming objects
    • 2.3.2 Basic Class symbol • Rectangle represents a class of objects • 3 compartments: Name, attributes , and operations or methods • Symbols indicate accessibility
    • 2.4.1 Class definition •Defined by using public class Person { private String name; the class keyword public Person(String theName) { •Public classes name = theName; defined in separate } } files •Filename must be the same as the class name
    • 2.4.2 Creating objects • Constructor methods are called when an object is created • All object data is stored in memory • Variables are a reference to the memory location
    • 2.4.3 Object methods • Mutator – Changes object data • Accessor – Retrieves object data • Methods with no arguments • Methods that require arguments • Method return values – Provide a result to the caller
    • 2.5.1 System class • Data stored by an object is member data • Data present in an object’s methods is called local or temporary data • Java.lang.System is a pre-defined object that can be used to perform system tasks System.out.println(“Hello World!”);