Where do objects come from? Objects are instances of classes We instantiate classes: –e.g.new chapter1.Terrarium() –There are three parts to this expression:

Slides:



Advertisements
Similar presentations
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
Advertisements

 2005 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
2/18/2008ITK 1681 Feb. 20, Wed. 8:00 – 9:30 pm STV Closed book, notes, and no computer is allowed. 2.Everyone is allowed to bring a self- prepared.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
1 Class members Class definitions consist of variable declarations and method definitions, collectively called members of the class. Variables declared.
Summary of the lecture We introduced the local variable dependency –This is a binary relationship (a relationship between two classes), similar to instantiation.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
Lecture #5 Agenda Cell phones off & name signs out Review Questions? UML class diagram introduction Our first class definition!
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
Syntax & terminology review While the following slides are not exactly what we did on the board (object diagrams are not shown here) they cover most of.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
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.
 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Chapter 3, More on Classes & Methods Clark Savage Turner, J.D., Ph.D. Copyright 2003 CSTurner, from notes and text.
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
1 Objects and Classes Introduction to Classes Object Variables and Object References Instantiating Objects Using Methods in Objects Reading for this Lecture:
Slides prepared by Rose Williams, Binghamton University Chapter 20 Java Threads Part II.
Where do objects come from? Objects are instances of classes We instantiate classes: –e.g.new chapter1.Terrarium() –There are three parts to this expression:
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Lecture #4 Agenda Cell phones off & name signs out Review Questions? Objects The birds-and-the-bees talk.
Slides prepared by Rose Williams, Binghamton University Chapter 5 Defining Classes II.
Chapter 3 Using Classes and Objects. 2 Creating Objects  A variable holds either a primitive type or a reference to an object  A class name can be used.
Fall 2005CSE 115/503 Introduction to Computer Science I1 Lecture #4 Agenda Announcements Review Questions? Classes and objects UML class diagrams Creating.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
CSE 115 Week 3 January 28 – February 1, Monday Announcements Software Installation Fest: 2/5 and 2/6 4pm – 7pm in Baldy 21 Software Installation.
Chapter 3 Using Classes and Objects. 2 Creating Objects  A variable holds either a primitive type or a reference to an object  A class name can be used.
Week 3 Recap CSE 115 – Spring Constructor Special capability of a class that sets up the initial state of the object. Constructor definitions are.
UML class diagrams (1) UML = Unified Modeling Language We use only class diagrams, not other UML diagrams Purpose: –keep OO concepts separate from implementation.
Fall 2005CSE 115/503 Introduction to Computer Science I1 Composition details Recall, composition involves 3 things: –Declaration of instance variable of.
CSE 115 Week 2 January , Wednesday Announcements Pick up Syllabus if you need one Pick up Syllabus if you need one Recitation Change Form.
Java Methods By J. W. Rider. Java Methods Modularity Declaring methods –Header, signature, prototype Static Void Local variables –this Return Reentrancy.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Classes and Class Members Chapter 3. 3 Public Interface Contract between class and its clients to fulfill certain responsibilities The client is an object.
Comments are for people Header comments supply basic information about the artifact.
C#C# Classes & Methods CS3260 Dennis A. Fairclough Version 1.1 Classes & Methods CS3260 Dennis A. Fairclough Version 1.1.
1 The String Class Every character string is an object in Java, defined by the String class Every string literal, delimited by double quotation marks,
Classes and Objects The basics. Object-oriented programming Python is an object-oriented programming language, which means that it provides features that.
Methods in Java. Program Modules in Java  Java programs are written by combining new methods and classes with predefined methods in the Java Application.
1 Chapter 8 – Classes and Object: A Deeper Look Outline 1 Introduction 2 Implementing a Time Abstract Data Type with a Class 3 Class Scope 4 Controlling.
Java™ How to Program, 10/e © Copyright by Pearson Education, Inc. All Rights Reserved.
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
PPL Applicative and Normal Form Verification, Type Checking and Inference.
Java™ How to Program, 9/e Presented by: Dr. José M. Reyes Álamo CET 3640 © Copyright by Pearson Education, Inc. All Rights Reserved.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
Programming Perl in UNIX Course Number : CIT 370 Week 6 Prof. Daniel Chen.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
 2006 Pearson Education, Inc. All rights reserved Classes: A Deeper Look, Part 1.
 2005 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
1 Predefined Classes and Objects Chapter 3. 2 Objectives You will be able to:  Use predefined classes available in the Java System Library in your own.
Today’s lecture Review chapter 5 go over exercises.
Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 6-1 Learning Objectives  Classes  Constructors  Principles of OOP  Class type member.
 2005 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
1 Creating Objects  A variable holds either a primitive type or a reference to an object  A class name can be used as a type to declare an object reference.
The Object-Oriented Thought Process Chapter 03
Chapter 3 Introduction to Classes, Objects Methods and Strings
Variables in Java A variable holds either
3 Introduction to Classes and Objects.
Java Primer 1: Types, Classes and Operators
University of Central Florida COP 3330 Object Oriented Programming
Chapter 3: Using Methods, Classes, and Objects
Chapter 3 Introduction to Classes, Objects Methods and Strings
Chapter 3 Introduction to Classes, Objects Methods and Strings
Week 3 Object-based Programming: Classes and Objects
Creating Objects A variable holds either a primitive value or a reference to an object A class name can be used as a type to declare an object reference.
Object Oriented Programming in java
Java Programming Language
Chapter 4 Constructors Section 4.4
Presentation transcript:

Where do objects come from? Objects are instances of classes We instantiate classes: –e.g.new chapter1.Terrarium() –There are three parts to this expression: new chapter1.Terrarium ()

new chapter1.Terrarium() ‘new’ is a “reserved word” in Java. This means that the word ‘new’ has a special meaning in the Java language. ‘new’ is the name of an operator whose job it is to create an instance of a given class chapter1.Terrarium is the name of the class we are instantiating. It is a compound name, consisting of a package name (chapter1) and the name of the class’ constructor (Terrarium), separated by a dot ‘.’ A constructor initializes the state of a newly created object. The parentheses delimit the argument list of the constructor call. In this case there are no arguments being passed along to the constructor, so the argument list is empty.

Packages A package is an organizational mechanism One analogy: –package::class –area code::phone number A class’ fully qualified name consists of its package name and its (unqualified) class name: –chapter1.Terrarium is a fully qualified class name –Terrarium is an unqualified class name

On to Eclipse package lecture; class EcoSystem { public EcoSystem() { }