Chapter 1 Object Orientation: Objects and Classes.

Slides:



Advertisements
Similar presentations
INTRODUCTION Chapter 1 1. Java CPSC 1100 University of Tennessee at Chattanooga 2  Difference between Visual Logic & Java  Lots  Visual Logic Flowcharts.
Advertisements

CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
Introduction to Object-Oriented Programming CS 21a: Introduction to Computing I First Semester,
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Objects and Classes First Programming Concepts. 14/10/2004Lecture 1a: Introduction 2 Fundamental Concepts object class method parameter data type.
Slides prepared by Rose Williams, Binghamton University Chapter 14 Generics and the ArrayList Class.
How to Create a Java program CS115 Fall George Koutsogiannakis.
Copyright by Scott GrissomCh 1 Objects and Classes Slide 1 Classes and Objects A Class refers to something in general describes a category of items a cookie.
Objects & Object-Oriented Programming (OOP) CSC 1401: Introduction to Programming with Java Week 15 – Lecture 1 Wanda M. Kunkle.
1 Fall 2007ACS-1903 Chapter 6: Classes Classes and Objects Instance Fields and Methods Constructors Overloading of Methods and Constructors Scope of Instance.
COMP 14: Intro. to Intro. to Programming May 23, 2000 Nick Vallidis.
9-Aug-15 Vocabulary. Programming Vocabulary Watch closely, you might even want to take some notes. There’s a short quiz at the end of this presentation!
Introduction to Object-Oriented Programming Lesson 01: Introduction
public static void main (String[] args)
+ Java vs. Javascript Jessi Style. + Java Compiled Can stand on its own Written once, run anywhere Two-stage debugging Java is an Object Oriented Programming.
Hello AP Computer Science!. What are some of the things that you have used computers for?
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
INTRODUCTION TO C PROGRAMMING LANGUAGE Computer Programming Asst. Prof. Dr. Choopan Rattanapoka and Asst. Prof. Dr. Suphot Chunwiphat.
Chapter 5 - Writing a Problem Domain Class Definition1 Chapter 5 Writing a Problem Domain Class Definition.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
Introduction to Programming Writing Java Beginning Java Programs.
CS 106 Introduction to Computer Science I 01 / 25 / 2010 Instructor: Michael Eckmann.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
Session One Introduction. Personal Introduction Role of programmers Robot Examination HUD & HID Uploading Code.
The Java Programming Language
JAVA JAVA is an object-oriented programming (OOP) language introduced by Sun Microsystems in In the Java programming language: A program is made.
Object Oriented Programming … and other things you need to program in java.
Lecture 2: Classes and Objects, using Scanner and String.
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Board Activity Find your seat on the seating chart Login – Remember your login is your first initial your last name and the last three numbers of your.
OBJECTS AND CLASSES CITS1001. Concepts for this lecture class; object; instance method; parameter; signature data type multiple instances; state method.
1 COS 260 DAY 2 Tony Gauvin. 2 Agenda Questions? Class roll call Blackboard Web Resources Objects and classes 1 st Mini quiz on chap1 terms and concepts.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
Chapter 1 Object Orientation: Objects and Classes.
Object-Oriented Programming. An object is anything that can be represented by data in a computer’s memory and manipulated by a computer program.
Working With Objects Tonga Institute of Higher Education.
Introduction to Programming Writing Java Beginning Java Programs.
JAVA Practical Creating our first program 2. Source code file 3. Class file 4. Understanding the different parts of our program 5. Escape characters.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
CS0007: Introduction to Computer Programming Classes: Documentation, Method Overloading, Scope, Packages, and “Finding the Classes”
Working With Objects Tonga Institute of Higher Education.
Hello Computer Science!. Below is an example of a Hello World program in JAVA. While it is only three lines of code, there are many things that are happening.
Salman Marvasti Sharif University of Technology Winter 2015.
Static?. Static Not dynamic class Widget { static int s; int d; // dynamic // or instance // variable }
Java FilesOops - Mistake Java lingoSyntax
Object Oriented Programming Criteria: P2 Date: 07/10/15 Name: Thomas Jazwinski.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
Objects and Classes Start on Slide 30 for day 2 Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Much of.
1.1: Objects and Classes msklug.weebly.com. Agenda: Attendance Let’s get started What is Java? Work Time.
© Peter Andreae Java Programs COMP 102 # T1 Peter Andreae Computer Science Victoria University of Wellington.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Learning Plan 6 Java Programming Intro to Object Oriented Programming.
2.1 First C Program. First Program Open visual studio, click new file Save as “programName.c” – Program must start with letter and have no spaces – Must.
Week 21 Introduction to Programming Ms. Knudtzon C Period Lecture 3.
Andrew(amwallis) Classes!
OBJECT ORIENTED PROGRAMMING
3 Introduction to Classes and Objects.
Object Oriented Programming
Chapter 3 GC 101 Java Fundamentals.
Console Output, Variables, Literals, and Introduction to Type
Lecturer: Mukhtar Mohamed Ali “Hakaale”
Java Programming with BlueJ
Chapter 3 Introduction to Classes, Objects Methods and Strings
Object Oriented Programming in java
Classes CS 21a: Introduction to Computing I
Introduction to Object-Oriented Programming
Presentation transcript:

Chapter 1 Object Orientation: Objects and Classes

Objects and Classes When you create a program using an object-oriented language, you are: –Creating a model of the problem –The model is built up from objects in the problem domain –Those objects must be represented in your program

Object vs. Class Let’s ask some questions about a student: –What color is his hair? –How tall is he? –What is his QCA?

Object vs. Class In order to answer these questions we need to know what student we are talking about. –This particular student is an instance of a student. In this example, the student is a class and the instance of the student is an object.

Object vs. Class A class is a generic example; a blue print if you will. An object is one particular instance of a class. It is sometimes said that you instantiate an object from a class

JAVA Conventions Names of Classes start with a Capital Letters. Names of objects start with lower case letters. This case convention is fairly well followed throughout the Java programming community.

BlueJ Let’s look at an example in BlueJ Shapes Sample from the Example folder Shapes Sample from the Example folder

Calling Methods When we right clicked on a object on the workbench in BlueJ, we got a popup menu with a bunch of function names listed. In Java, these functions are called methods When we chose one of these methods for the object to perform, we called or invoked the method When the method requires information from the programmer, the method is said to have a parameter

Method Signatures A method signature provides information about the method. –It tells us the name of the method –Whether or not the method requires a parameter –What type of information is returned from the method

Data Types The values a parameter can take Examples –int – whole numbers –String – a section of text Pitfall – forgetting the double quotes around a string. You’ll get a message like “Error: undefined variable”

Multiple Instances Object-oriented programming (OOP) allows for creating more than one object from the same class. The internal state of the object allows the computer to tell the different objects apart.

State All of the attributes that define an object is referred to as the object’s state Java refers to the individual attributes as fields

What is an object? All objects of the same class have the same fields (and methods). The values stored in those fields are different. The class indicates what fields and methods each object will have.

Object Interaction Objects can create other objects and invoke those objects methods Most Java programs have objects that will do just this Question: How do we do this?

Source Code Like most programming languages, Java is written using plain text files or source code files The source code tells the program how objects are created and how the objects will interact After a source code file is written, it must be compiled so that the Java Virtual Machine (JVM) can interpret it

Return Values Some methods not only take parameters, but give something back to you. These methods are said to have a return value You can tell this in the signature –String getName() This methods returns a String –void moveRight() This method returns void (nothing)

Homework 1.2, 1.5, 1.6, 1.9, 1.11, 1.18, 1.26

Quiz Explain the difference between an object and a class.