University of Central Florida COP 3330 Object Oriented Programming

Slides:



Advertisements
Similar presentations
Chapter 22 Implementing lists: linked implementations.
Advertisements

Topic 10 Java Memory Management. 1-2 Memory Allocation in Java When a program is being executed, separate areas of memory are allocated for each class.
Classes and Objects: Recap A typical Java program creates many objects which interact with one another by sending messages. Through the objects interactions,
Road Map Introduction to object oriented programming. Classes
Lecture 2 Classes and objects, Constructors, Arrays and vectors.
Intro to Java Part II. Calling an Objects Methods Use qualified names to call the objects methods. To form – you append the method name to an object reference.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Evan Korth New York University Computer Science I Classes and Objects Professor: Evan Korth New York University.
Evan Korth New York University Computer Science I Classes and Objects Professor: Evan Korth New York University.
Classes and Objects  A typical Java program creates many objects which interact with one another by sending messages. Through the objects interactions,
Terms and Rules Professor Evan Korth New York University (All rights reserved)
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
1 Classes and Objects. 2 Outlines Class Definitions and Objects Member Functions Data Members –Get and Set functions –Constructors.
Programming Languages and Paradigms Object-Oriented Programming.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
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)
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.
Lecture :2 1.  DEFENTION : Java is a programming language expressly designed for use in the distributed environment of the Internet. It was designed.
Copyright © 2002, Systems and Computer Engineering, Carleton University a-JavaReview.ppt * Object-Oriented Software Development Unit.
More about Class 靜宜大學資工系 蔡奇偉副教授 ©2011. 大綱 Instance Class Members Class members can be associated with an instance of the class or with the class as a.
Object Based Programming Chapter 8. 2 In This Chapter We will learn about classes Garbage Collection Data Abstraction and encapsulation.
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.
Programming in Java CSCI-2220 Object Oriented Programming.
Visual C# 2012 for Programmers © by Pearson Education, Inc. All Rights Reserved.
C# Classes and Inheritance CNS 3260 C#.NET Software Development.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Dale Roberts Object Oriented Programming using Java - Final and Static Keywords Dale Roberts, Lecturer Computer Science, IUPUI
 Constructor  Finalize() method  this keyword  Method Overloading  Constructor Overloading  Object As an Argument  Returning Objects.
Introduction to Java Chapter 7 - Classes & Object-oriented Programming1 Chapter 7 Classes and Object-Oriented Programming.
COP INTERMEDIATE JAVA Designing Classes. Class Template or blueprint for creating objects. Their definition includes the list of properties (fields)
Classes. Constructor A constructor is a special method whose purpose is to construct and initialize objects. Constructor name must be the same as the.
Constructors & Garbage Collection Ch. 9 – Head First Java.
 Objects versus Class  Three main concepts of OOP ◦ Encapsulation ◦ Inheritance ◦ Polymorphism  Method ◦ Parameterized ◦ Value-Returning.
Finalizers, this reference and static Sangeetha Parthasarathy 06/13/2001.
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
CSI 3125, Preliminaries, page 1 Class. CSI 3125, Preliminaries, page 2 Class The most important thing to understand about a class is that it defines a.
1 C# - Inheritance and Polymorphism. 2 1.Inheritance 2.Implementing Inheritance in C# 3.Constructor calls in Inheritance 4.Protected Access Modifier 5.The.
 Static  Example for Static Field  Example for Static Method  Math class methods  Casting  Scope of Declaration  Method Overloading  Constructor.
YG - CS Concept of Encapsulation What is encapsulation? - data and functions/methods are packaged together in the class normally.
5.1 Basics of defining and using classes A review of class and object definitions A class is a template or blueprint for an object A class defines.
Object and Classes อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา Chapter 3.
Internet Computing Module II. Syllabus Creating & Using classes in Java – Methods and Classes – Inheritance – Super Class – Method Overriding – Packages.
COP INTERMEDIATE JAVA Inheritance, Polymorphism, Interfaces.
Memory Management in Java Mr. Gerb Computer Science 4.
JAVA ACCESS MODIFIERS. Access Modifiers Access modifiers control which classes may use a feature. A classes features are: - The class itself - Its member.
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
Object Based Programming Chapter 8. 2 Contrast ____________________ Languages –Action oriented –Concentrate on writing ________________ –Data supports.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
The Object-Oriented Thought Process Chapter 03
Static data members Constructors and Destructors
Java Primer 1: Types, Classes and Operators
Unit-2 Objects and Classes
University of Central Florida COP 3330 Object Oriented Programming
Chapter 3: Using Methods, Classes, and Objects
Selenium WebDriver Web Test Tool Training
Road Map Introduction to object oriented programming. Classes
This pointer, Dynamic memory allocation, Constructors and Destructor
Object Based Programming
Introduction to Classes
CSC 113 Tutorial QUIZ I.
Chapter 3 Introduction to Classes, Objects Methods and Strings
Object Oriented Programming in java
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.
Assessment – Java Basics: Part 1
.Net Framework Details Imran Rashid CTO at ManiWeber Technologies.
Object Oriented Programming in java
Chapter 9 Objects and Classes Part 01
SPL – PS4 C++ Advanced OOP.
Presentation transcript:

University of Central Florida COP 3330 Object Oriented Programming

Agenda Objects in depth

Objects

Creating an object A class provides the blueprint for objects; create an object from a class Declaration: The variable declarations that associate a variable name with an object type; does NOT create an object Instantiation: The new keyword is a Java operator that creates the object; memory is allocated; a reference to that memory is returned Note: The phrase "instantiating a class" means the same thing as "creating an object." When an object is created, creating an "instance" of a class, therefore "instantiating" a class.

Creating an object A class provides the blueprint for objects; create an object from a class Initialization: The new operator is followed by a call to a constructor, which initializes the new object All classes have at least one constructor. if a class does not explicitly declare a constructor the Java compiler automatically provides a no-argument constructor, called the default constructor This default constructor calls the class parent's no-argument constructor, or the Object constructor if the class has no other parent If the parent has no constructor the compiler will reject the program

Using objects Object fields are accessed by their name which must be unambiguous Code outside the object's class must use an object reference or expression, followed by the dot (.) operator, followed by a simple field name objectReference.fieldName Objects of the same type have their own copy of the same instance fields

Using objects use an object reference to invoke an object's method by appending the method's simple name to the object reference, with an intervening dot operator (.) Don’t forget the enclosing parentheses for any arguments to the method. If the method does not require any arguments, use empty parentheses

Garbage Collection Some object-oriented languages require that you keep track of all created objects and explicitly destroy them when they are no longer needed Managing memory explicitly is tedious and error-prone The Java platform allows you to create as many objects as required (limited, of course, by what your system can handle) Do not have to destroy them The Java runtime environment deletes objects when it determines that they are no longer being used; this process is called garbage collection. An object is eligible for garbage collection when there are no more references to that object The Java runtime environment has a garbage collector that periodically frees the memory used by objects that are no longer referenced. The garbage collector does its job automatically when it determines that the time is right.