Re-Intro to Object Oriented Programming

Slides:



Advertisements
Similar presentations
Looking inside classes Fields, Constructors & Methods Week 3.
Advertisements

Based on Java Software Development, 5th Ed. By Lewis &Loftus
Chapter 4&5 Defining Classes Copyright © 2010 Pearson Addison-Wesley. All rights reserved.
1 Classes, Encapsulation, Methods and Constructors (Continued) Class definitions Instance data Encapsulation and Java modifiers Method declaration and.
Road Map Introduction to object oriented programming. Classes
Objects and Classes First Programming Concepts. 14/10/2004Lecture 1a: Introduction 2 Fundamental Concepts object class method parameter data type.
1 Classes Overview l Classes as Types l Declaring Instance Variables l Implementing Methods l Constructors l Accessor and Mutator Methods.
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
C# Programming: From Problem Analysis to Program Design1 Creating Your Own Classes C# Programming: From Problem Analysis to Program Design 3rd Edition.
Understanding class definitions Looking inside classes 3.0.
Terms and Rules Professor Evan Korth New York University (All rights reserved)
Understanding class definitions Looking inside classes.
State,identity and behavior of objects Sem III K.I.R.A.S.
Classes in C++ Bryce Boe 2012/08/15 CS32, Summer 2012 B.
Java Methods By J. W. Rider. Java Methods Modularity Declaring methods –Header, signature, prototype Static Void Local variables –this Return Reentrancy.
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
COP INTERMEDIATE JAVA Designing Classes. Class Template or blueprint for creating objects. Their definition includes the list of properties (fields)
Java Classes Appendix C © 2015 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Classes CS 21a: Introduction to Computing I First Semester,
ACO 101: Introduction to Computer Science Anatomy Part 2: Methods.
CH 8 : Enhancing Classes - Review QUICK REVIEW : A Class defines an entity’s (Object’s) data and the actions or behaviors (Methods) associated with that.
Chapter 4 -2 part Writing Classes 5 TH EDITION Lewis & Loftus java Software Solutions Foundations of Program Design © 2007 Pearson Addison-Wesley. All.
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
JAVA Classes Review. Definitions Class – a description of the attributes and behavior of a set of computational objects Constructor – a method that is.
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
Understanding class definitions
Chapter 4 Introduction to Classes, Objects, Methods and strings
COP INTERMEDIATE JAVA Designing Classes. Class Template or blueprint for creating objects. Their definition includes the list of properties (fields)
Chapter 3 (B) 3.5 – 3.7.  Variables declared in a function definition’s body are known as local variables and can be used only from the line of their.
Chapter 4&5 Defining Classes Copyright © 2010 Pearson Addison-Wesley. All rights reserved.
Chapter 3 Introduction to Classes and Objects Definitions Examples.
Java Classes Chapter 1. 2 Chapter Contents Objects and Classes Using Methods in a Java Class References and Aliases Arguments and Parameters Defining.
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
Introduction To Objects Oriented Programming Instructor: Mohammed Faisal.
Object Oriented Programming and Data Abstraction Rowan University Earl Huff.
1 Class and Object Lecture 7. 2 Classes Classes are constructs that define objects of the same type. A Java class uses instance variables to define data.
05 Method Calling. 2 What is a Method? Declaring a Method Method Calling Method Call Stack Parameter Passing Pass by Value Outline.
 An object is basically anything in the world that can be created and manipulated by a program.  Examples: dog, school, person, password, bank account,
Classes CS 162 (Summer 2009). Parts of a Class Instance Fields Methods.
CompSci 230 S Programming Techniques
Objects as a programming concept
Haidong Xue Summer 2011, at GSU
Java Primer 1: Types, Classes and Operators
Intro To Classes Review
Creating Your OwnClasses
Methods The real power of an object-oriented programming language takes place when you start to manipulate objects. A method defines an action that allows.
HIGHLEVEL REVIEW Chapter 9 Objects and Classes
Classes In C#.
CS 200 Creating Classes Jim Williams, PhD.
Understanding class definitions
Corresponds with Chapter 7
An Introduction to Java – Part II
Classes & Objects: Examples
Classes, Encapsulation, Methods and Constructors (Continued)
Implementing Non-Static Features
Chapter 4 Writing Classes.
More on Classes and Objects
Class Everything if Java is in a class. The class has a constructor that creates the object. public class ClassName private Field data (instance variables)
Understanding class definitions
JAVA CLASSES.
Instance Method – CSC142 Computer Science II
Object Oriented Programming in java
CIS 199 Final Review.
CS 200 Creating Classes Jim Williams, PhD.
Properties.
Classes CS 21a: Introduction to Computing I
Dr. R Z Khan Handout-3 Classes
CS 1054: Lecture 2, Chapter 1 Objects and Classes.
Classes and Objects Systems Programming.
Day 11 The Last Week!.
Presentation transcript:

Re-Intro to Object Oriented Programming Prof. Elizabeth Adams

What are objects? Objects are classes For example, we can have a Car object also known as a Car class The Car class has attributes or fields that belong to every existing car For example: Serial number Color Maker Number of doors

What do you call a particular object? an instance of the class Each instance of the class will have all of the attributes of the class

What does a class consist of? State – which is reflected in its attributes Behavior – which is reflected in its actions carried out by its methods

How do you create an instance of a class? You use the new operator

Can you have more than one instance of a class? yes

How do you manipulate object instances By calling or invoking methods aka functions or we can pass messages

What do methods consist of? Header (name and a parameter list which MAY be empty) and a body

What are parameters? “stuff” that the methods need to pass additional values into the object instance or content of the messages that are being passed to the object instance

What is the signature of a method? What everyone agrees is part of the signature is the method (function) name, number, type and order of parameters. What others include is the return type. We have been using the 1st definition and calling the 2nd definition the method header

Can you re-use (concurrently) method names? Yes, as long as either the number, type or order of the parameters is different.

What kinds of methods are there? Constructor – creates a new object instance Accessor – return information about the state of an object instance Mutator – changes the state of an object

The “condition” of its attributes What is state? The “condition” of its attributes

How can you determine state? By using its accessor methods

When we talk about attributes of a class, what are other names we use? Instance variables or fields or properties

public class Slogan //Listing 6 public class Slogan //Listing 6.3 – page 297 { private String phrase; private static int count = 0; public Slogan (String str) // constructor { phrase = str; count++; } public String toString() // returns a String { return phrase; } public static int getCount () // returns a count of # slogans created { return count; } } Discuss modifiers: static and private Discuss accessor, constructor, mutator