Classes and Objects CSC 171 FALL 2004 LECTURE 2. LABS Labs start this week. Go to your 2 nd (Wed or Thurs) lab Expect something like the programming exercises.

Slides:



Advertisements
Similar presentations
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Advertisements

Object Orientated Programming OOP. What is it? What is this?
Introduction to Object-Oriented Programming CS 21a: Introduction to Computing I First Semester,
The Java Programming Language  Simple – but abstract  Safe  Platform-independent ("write once, run anywhere")  Has a Rich growing library  Designed.
ALGORITHMS CSC 171 LECTURE 1. What is “Computer Science”? What is “Science”? What is a “Computer”? What is “Computation”?
How to Create a Java program CS115 Fall George Koutsogiannakis.
How do we make our HelloTester.java program do something? The java in our HelloTester.java file won’t do anything by itself. We need to tell the computer.
CHAPTER 2 OBJECTS AND CLASSES Goals: To understand the concepts of classes and objects To realize the difference between objects and object references.
Huron High School AP Computer Science Instructor: Kevin Behemer S. Teacher: Guillermo Moreno.
Aalborg Media Lab 21-Jun-15 Software Design Lecture 1 “ Introduction to Java and OOP”
HST 952 Computing for Biomedical Scientists Lecture 2.
Classes and Objects in Java
Methods CSC 171 FALL 2004 LECTURE 3. Methods Variables describe static aspects – “nouns” Methods describe dynamic aspects – “verbs”, “behaviors” – Methods.
Datalogi A 2: 15/9. Java Slides based on Horstmann chapter 2&3 Objects and classes Import, methods, references Implementing a class.
Java Overview February 4, /4/2004 Assignments Due – Homework 1 Due – Reading and Warmup questions Project 1 – Basic Networking.
Object-oriented analysis (OOA) techniques are used to (1) study existing objects to see if they can be reused or adapted for new uses, and (2) define new.
ALGORITHMS CSC 171 LECTURE 1. What is “Computer Science”? What is “Science”? What is a “Computer”? What is “Computation”?
OOP and Graphics. Object Oriented Programming The ‘classic’ point of view of a programmer was that the program instructions were the active part, the.
Unit 2: Java Introduction to Programming 2.1 Initial Example.
Copyright 2010 by Pearson Education Building Java Programs Chapter 8 Lecture 8-2: Object Behavior (Methods) and Constructors reading:
Copyright 2008 by Pearson Education Building Java Programs Chapter 9 Lecture 9-4: Interfaces reading: self-check: exercises: #11.
Lecture 1 Introduction to Java MIT- AITI 2004 What is a Computer Program? For a computer to be able to do anything (multiply, play a song, run a word.
CompSci 42.1Intro to Java Anatomy of a Class & Terminology Running and Modifying a Program.
Introduction to Object-Oriented Programming
Static Keyword. What is static The static keyword is used when a member variable of a class has to be shared between all the instances of the class. All.
©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 1 Chapter 1 Introduction.
Lecture 1 Introduction to Java MIT-AITI Ethiopia 2004.
CSc2310 tutoring session, week 8 Fall, 2012 Haidong Xue 5:30pm—8:30pm 10/23/2012 and 10/24/2012 -Using Exceptions -Homework 4.
Programming Concept Chapter I Introduction to Java Programming.
Computer Science II 810:062 Section 01. How is CS I different from CS II? When you teach Java there are a series of decisions that have to be made…
Chapter 3: Developing Class Methods Object-Oriented Program Development Using Java: A Class-Centered Approach.
Object Oriented Programming Lecture 5: BallWorld.
Programming With Java ICS201 University Of Hail1 Chapter 13 Interfaces.
1 CSC 110AA Introduction to Computer Science for Majors - Spring 2003 Class 5 Chapter 2 Type Casting, Characters, and Arithmetic Operators.
Jens Dalsgaard Nielsen Jan Dimon Bendtsen Dept. of Electronic Systems Basic Programming INS-basis GF, PDP and HST.
Anatomy.1 Anatomy of a Class & Terminology. Anatomy.2 The Plan Go over MoveTest.java from Big Java Basic coding conventions Review with GreeterTest.java.
 Instructor: Dr. Jason Nichols –  Office Hours: – 9:30-10:30 M/W/F or by appointment – Business Building.
Rina System development with Java Instructors: Rina Zviel-Girshin Lecture 4.
CS305j Introduction to Computing Classes 1 Topic 23 Classes – Part I "A 'class' is where we teach an 'object' to behave." -Rich Pattis Based on slides.
ACM/JETT Workshop - August 4-5, : Defining Classes in Java.
Objective You will be able to define the basic concepts of object-oriented programming with emphasis on objects and classes by taking notes, seeing examples,
A High Flying Overview CS139 – Fall 2006 How far we have come.
COME 339 WEEK 1. Example: The Course Class 2 TestCourceRunCourse.
Methods.
CompSci 42.1Intro to Java Anatomy of a Class & Terminology Running and Modifying a Program.
CSC 212 – Data Structures Lecture 6: Static and non-static members.
Methods CSC 171 FALL 2001 LECTURE 3. History The abacus.
A Simple Object Oriented Program public class Simple { public static void main (String [] args) { System.out.println(“howdy”); } System.out is an object.
Java Methods and Applications CSIS 3701: Advanced Object Oriented Programming.
Introduction to programming in java
Re-Intro to Object Oriented Programming
Building Java Programs
Classes and Objects in Java
ALGORITHMS CSC 171 LECTURE 1.
Tonga Institute of Higher Education
Building Java Programs
Classes Lecture 7 from Chapter /1/11.
Classes and Objects in Java
class PrintOnetoTen { public static void main(String args[]) {
Building Java Programs
Building Java Programs
CLASSES, AND OBJECTS A FIRST LOOK
Overview of Java 6-Apr-19.
AN INTRODUCTION TO OBJECTS AND CLASSES
Introduction to Object-Oriented Programming
Building Java Programs
Building Java Programs
Classes and Objects in Java
Introduction to Computer Science and Object-Oriented Programming
class Box { double width; double height; double depth; }
Presentation transcript:

Classes and Objects CSC 171 FALL 2004 LECTURE 2

LABS Labs start this week. Go to your 2 nd (Wed or Thurs) lab Expect something like the programming exercises (P1.1 – P1.4) from chapter #1 You may use “notepad” and the “command prompt”

History The abacus

Questions What is an “object”? What is a “class”? What is the difference between an object and a class? How do I “write a class”? How do I “make an object”?

What are objects? Object: entity that you can manipulate in your programs (by invoking methods) Each object belongs to a class Class: Set of objects with the same behavior Class determines legal methods "Hello".println() // Error "Hello".length() // OK

Classes and Objects Object oriented programs – Define classes of objects – Make specific object out of class definitions – Run by having the objects interact (communicate – pass messages) A class is a type of thing – Instructor An object is a specific thing – Ted An object is an instance of a class

ANALOGY RUBBER STAMPING – The STAMP is the “Class definition” – The IMPRESSION is the “object”

DESIGN EXERCISE Think about the “class of things” we call “students” What is the “data”? What are the “behaviors”?

EXAMPLE A rectangle has a location, width, and height (5,10) 20 30

Making an object: CONSTRUCTION new Rectangle(5,10,20,30)

Reference to an object Rectangle cerealBox = new Rectangle(5,10,20,30);

Using references System.out.println(“The location is : (” + cerealBox.x + “,” + cerealBox.y);

Multiple references Rectangle cerealBox = new Rectangle(5,10,20,30); Rectangle r = cerealBox;

Programming Example The “Instructor” class – Instructors have names

Review A Computer Program //Really, A Class definition! public class myFirstProgram { public static void main(String args[]){ System.out.println(“Hello, CSC171”); }

Questions What is an “object”? – An instance of a class What is a “class”? – A definition of a set of objects What is the difference between an object and a class? How do I “write a class”? – With the “class” pattern How do I “make an object”? – By invoking a constructor