Today’s lecture Review chapter 5 go over exercises.

Slides:



Advertisements
Similar presentations
Arrays.
Advertisements

CS0007: Introduction to Computer Programming Introduction to Classes and Objects.
Written by: Dr. JJ Shepherd
CSCI 1100/1202 April 3, Testing A program should be executed multiple times with various input in an attempt to find errors Debugging is the process.
Lecture 31 File I/O -Part 2 COMP1681 / SE15 Introduction to Programming.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
Road Map Introduction to object oriented programming. Classes
Evan Korth New York University Computer Science I Classes and Objects Professor: Evan Korth New York University.
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.
Evan Korth New York University Computer Science I Classes and Objects Professor: Evan Korth New York University.
Alice in Action with Java
Terms and Rules Professor Evan Korth New York University (All rights reserved)
Arrays, Loops weeks 4-6 (change from syllabus for week 6) Chapter 4.
Miscellaneous OOP topics Java review continued. Simple data types & wrapper classes Simple data types are the built-in types provided as part of the Java.
Sanjay Goel, School of Business, University at Albany, SUNY 1 MSI 692: Special Topics in Information Technology Lecture 4: Strings & Arrays Sanjay Goel.
CS0007: Introduction to Computer Programming Introduction to Arrays.
Dale Roberts Object Oriented Programming using Java - Class Constructors Dale Roberts, Lecturer Computer Science, IUPUI Department.
Copyright 2010 by Pearson Education Building Java Programs Chapter 8 Lecture 8-2: Object Behavior (Methods) and Constructors reading:
Programming Principles Data types and Variables. Data types Variables are nothing but reserved memory locations to store values. This means that when.
CSC 212 – Data Structures Lecture 3: Fields, Methods, & Constructors.
Programming Languages and Paradigms Object-Oriented Programming.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
Announcements  If you need more review of Java…  I have lots of good resources – talk to me  Use “Additional Help” link on webpage  Weekly assignments.
Data Objects (revisited) Recall that values are stored in data objects, and that each data object holds one value of a particular type. Data objects may.
Lec 19 Array Intro. Agenda Arrays—what are they Declaring Arrays Constructing Arrays Accessing Array cells.
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.
Memory Allocation Recall: we use a reference variable to refer to instances of a class. The value in a reference variable is, essentially, a pointer to.
Mason Vail.  A data type definition – “blueprint for objects”  Includes properties and/or methods ◦ “instance” data / methods – specific to one object.
CNIT 133 Interactive Web Pags – JavaScript and AJAX Advanced topic - variable.
Lecture Set 11 Creating and Using Classes Part B – Class Features – Constructors, Methods, Fields, Properties, Shared Data.
CMSC 202 Arrays. Aug 6, Introduction to Arrays An array is a data structure used to process a collection of data that is all of the same type –An.
Chapter 8: Arrays.
Announcements  If you need more review of Java…  I have lots of good resources – talk to me  Use “Additional Help” link on webpage  Weekly assignments.
Copyright 2010 by Pearson Education Building Java Programs Chapter 8 Lecture 8-2: Object Behavior (Methods) and Constructors, Encapsulation, this reading:
Java Objects and Classes. Overview n Creating objects that belong to the classes in the standard Java library n Creating your own classes.
Constructors CMSC 202. Object Creation Objects are created by using the operator new in statements such as… The following expression invokes a special.
P Chapter 2 introduces Object Oriented Programming. p OOP is a relatively new approach to programming which supports the creation of new data types and.
Pointers in C++. 7a-2 Pointers "pointer" is a basic type like int or double value of a pointer variable contains the location, or address in memory, of.
More About Objects and Methods Chapter 5. Outline Programming with Methods Static Methods and Static Variables Designing Methods Overloading Constructors.
Chapter 7: Characters, Strings, and the StringBuilder.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Database Terms Hernandez, Chapter 3. Data/Information The values you store in the database are data. Pieces of Data in and of themselves is not particularly.
In Java.... Variables contain the values of primitive data types Value Types.
Method Overloading  Methods of the same name can be declared in the same class for different sets of parameters  As the number, types and order of the.
Chapter 5 Classes and Methods II Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
Today’s lecture Review of chapter 8 Go over examples.
 Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. 
1 Introduction to Object Oriented Programming Chapter 10.
Java Generics. Lecture Objectives To understand the objective of generic programming To be able to implement generic classes and methods To know the limitations.
 2016, Marcus Biel, Marcus Biel, Software Craftsman Identity vs Equality in Java
Memory Management in Java Mr. Gerb Computer Science 4.
Copyright 2010 by Pearson Education Building Java Programs Chapter 8 Lecture 8-2: Object Behavior (Methods) and Constructors, Encapsulation, this reading:
Reminder About Functions
3 Introduction to Classes and Objects.
Haidong Xue Summer 2011, at GSU
Java Primer 1: Types, Classes and Operators
Intro To Classes Review
CLASS DEFINITION (FIELDS)
Building Java Programs
Cs212: Data Structures Computer Science Department Lecture 2: Arrays.
CS100J Lecture 8 Previous Lecture This Lecture Programming Concepts
More About Objects and Methods
C++ Programming ㅎㅎ String OOP Class Constructor & Destructor.
Building Java Programs
Chap 2. Identifiers, Keywords, and Types
Chapter 4 Constructors Section 4.4
String Objects & its Methods
Presentation transcript:

Today’s lecture Review chapter 5 go over exercises

Classes and Objects What is a class? (What do we place in a class?) What is an object? (where do we create them?) How do we create a class? How do we create an object? How do we use an object?

Object Uniqueness Multiple objects of one type can be created that are distinct. Each occupies a separate spot in memory. // create many objects Knapsack knap1 = new Knapsack(); Knapsack knap2 = new Knapsack(); knap1.size = 5; knap2.size = 8; System.out.println(knap1.size); System.out.println(knap2.size);

Objects are values Objects are just values of a particular type (the given class type). "Every expression has a type": class-definitions are types too! Object-yielding expressions (yield a value of a reference type): constructor calls methods with a return type that is a class Nothing Special… Arrays of a reference type work just like arrays of primitive types. Expressions involving reference types are still just expressions. Variables can store reference types.

Default Constructors Default Constructor: Java provides a default constructor definition when none is present in a class: all instance variables get default values: primitive types get 0, 0.0, false, or ' ' ; reference types (class types) get the null value. null is a special value: it represents a value of any reference type but has no actual reference value (no instance variables, no methods). Attempting to use null like an actual object is a very common run-time error.

Let’s go over the exercises

Questions?