Mason Vail.  A data type definition – “blueprint for objects”  Includes properties and/or methods ◦ “instance” data / methods – specific to one object.

Slides:



Advertisements
Similar presentations
CS0007: Introduction to Computer Programming Introduction to Classes and Objects.
Advertisements

CSCI 1100/ , 6.2, 6.4 April 12, 15, 17.
Lecture 6 b Last time: array declaration and instantiationarray declaration and instantiation array referencearray reference bounds checkingbounds checking.
1 Objects, Classes, and Packages “Static” Classes Introduction to Classes Object Variables and Object References Instantiating Objects Using Methods in.
OBJECT-ORIENTED PROGRAMMING. What is an “object”? Abstract entity that contains data and actions Attributes (characteristics) and methods (functions)
Road Map Introduction to object oriented programming. Classes
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
C#.NET C# language. C# A modern, general-purpose object-oriented language Part of the.NET family of languages ECMA standard Based on C and C++
June 1, 2000 Object Oriented Programming in Java (95-707) Java Language Basics 1 Lecture 3 Object Oriented Programming in Java Language Basics Classes,
Object Oriented Programming.  OOP Basic Principles  C++ Classes  September 2004  John Edgar 22.
ECE122 L6: Problem Definition and Implementation February 15, 2007 ECE 122 Engineering Problem Solving with Java Lecture 6 Problem Definition and Implementation.
1 Classes, Encapsulation, Methods and Constructors Class definitions Scope of Data –Instance data –Local data The this Reference Encapsulation and Java.
Classes, Encapsulation, Methods and Constructors
Terms and Rules Professor Evan Korth New York University (All rights reserved)
Classes with multiple methods Part 1. Review of classes & objects Early on, we learned that objects are the basic working units in object-oriented programs.
1 Fall 2007ACS-1903 Chapter 6: Classes Classes and Objects Instance Fields and Methods Constructors Overloading of Methods and Constructors Scope of Instance.
Data Abstraction and Object- Oriented Programming CS351 – Programming Paradigms.
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
C++ Object Oriented 1. Class and Object The main purpose of C++ programming is to add object orientation to the C programming language and classes are.
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.
Java Classes Appendix C © 2015 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
CSCI-383 Object-Oriented Programming & Design Lecture 13.
CH 8 : Enhancing Classes - Review QUICK REVIEW : A Class defines an entity’s (Object’s) data and the actions or behaviors (Methods) associated with that.
JAVA BASICS Prepared by The Smartpath Information Systems
Java Software Solutions Lewis and Loftus Chapter 4 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Objects and Classes -- Introduction.
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
CSSE501 Object-Oriented Development. Chapter 4: Classes and Methods  Chapters 4 and 5 present two sides of OOP: Chapter 4 discusses the static, compile.
More About Objects and Methods Chapter 5. Outline Programming with Methods Static Methods and Static Variables Designing Methods Overloading Constructors.
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
© 2004 Pearson Addison-Wesley. All rights reserved September 12, 2007 Encapsulation ComS 207: Programming I (in Java) Iowa State University, FALL 2007.
Comp 248 Introduction to Programming Chapter 4 & 5 Defining Classes Part B Dr. Aiman Hanna Department of Computer Science & Software Engineering Concordia.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
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.
08 Encapsulation and Abstraction. 2 Contents Defining Abstraction Levels of Abstraction Class as Abstraction Defining a Java Class Instantiating a Class.
Object-Oriented Programming Chapter Chapter
Chapter 10: Classes and Data Abstraction. Objectives In this chapter, you will: Learn about classes Learn about private, protected, and public members.
Final Review. From ArrayLists to Arrays The ArrayList : used to organize a list of objects –It is a class in the Java API –the ArrayList class uses an.
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
Introduction to Object-Oriented Programming Lesson 2.
Java Classes Chapter 1. 2 Chapter Contents Objects and Classes Using Methods in a Java Class References and Aliases Arguments and Parameters Defining.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
Access Specifier. Anything declared public can be accessed from anywhere. Anything declared private cannot be seen outside of its class. When a member.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
Chapter 10: Classes and Data Abstraction. Classes Object-oriented design (OOD): a problem solving methodology Objects: components of a solution Class:
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.
Outline Anatomy of a Class Encapsulation Anatomy of a Method Copyright © 2014 Pearson Education, Inc.
Comp1004: Building Better Objects II Encapsulation and Constructors.
© 2004 Pearson Addison-Wesley. All rights reserved3-1 Objects Declaration: String title;  title (object variable) of type String( Class )  title is just.
Classes CS 162 (Summer 2009). Parts of a Class Instance Fields Methods.
Geoff Holmes and Bernhard Pfahringer COMP206-08S General Programming 2.
Computer Programming II Lecture 5. Introduction to Object Oriented Programming (OOP) - There are two common programming methods : procedural programming.
Object Oriented Programming. Constructors  Constructors are like special methods that are called implicitly as soon as an object is instantiated (i.e.
Object-Oriented Design
Java Primer 1: Types, Classes and Operators
Object-Oriented Programming & Design Lecture 14 Martin van Bommel
Java Review: Reference Types
Classes In C#.
Encapsulation & Visibility Modifiers
Corresponds with Chapter 7
Encapsulation and Constructors
Outline Writing Classes Copyright © 2012 Pearson Education, Inc.
Implementing Non-Static Features
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.
Outline Anatomy of a Class Encapsulation Anatomy of a Method
Object-Oriented Programming
Classes and Objects CGS3416 Spring 2019.
Presentation transcript:

Mason Vail

 A data type definition – “blueprint for objects”  Includes properties and/or methods ◦ “instance” data / methods – specific to one object (instance) of the class ◦ “static” or “class” data / methods – belongs to the class itself, shared by all objects of the type

 One instance of a data type  Looks and acts like other objects of the same type, but has its own identity and state independent of other objects

 One of the central pillars of object-oriented design  Idea that each object is in control of its own state (instance data) and outsiders are required to interact with the object through its limited public interface (set of methods)

 Visibility regulates the exposure of data and methods ◦ “public” – accessible to any outside entity with a reference to the object ◦ “protected” – default visibility – accessible to child objects or any other entity defined in the same package ◦ “private” – accessible only within the class/object  All data / methods should be private until a good reason is given to relax visibility

 A named set of statements within a class that carry out a specific task  Public methods make up the public interface of an object  Protected/private methods generally serve as supporting utility methods for carrying out intermediate tasks for the object

 The class containing the main() method, where a program begins  The class invoked by name when launching the Java Runtime Environment (JRE)

 The most basic linear data structure for storing multiple values of the same type  In some languages, they are a primitive data type, but in Java arrays are objects, though they have special syntax that makes them look a little different than other objects

 As objects, arrays must be instantiated with a constructor call before they can be used ◦ int[] a = new int[10]; //creates an array with room for 10 ints  The size of an array, once instantiated, is immutable

 Arrays can be multidimensional – each dimension can be of a different size  2D arrays (“tables”) are common  The first dimension of a 2D array is commonly considered to be the row reference  The second dimension of a 2D array is commonly considered to be the column

 Any multidimensional array can be thought of as an “array of arrays” until the last dimension is accessed and an individual value of the array type is reached  int[][] someArray = new int[5][10]; ◦ someArray is an array of int[]s of length 5 ◦ someArray[0] is in int[] of length 10

 A primitive variable is a named memory location containing a value of the primitive type  An object reference variable contains the address of an object somewhere else in memory

 Making a copy of a primitive variable duplicates the value, after which the two variables have no effect on the other  Making a copy of an object reference creates an alias – a duplicate reference to the same object – so changes can be made to the object via any of its aliased references  Copying an object requires instantiating a new, independent object and explicitly duplicating the state of the original object in the new object

 A collection of bodiless, abstract method signatures defined in a.java file  May be implemented by one or more classes  Not a class – may not be instantiated

 Accessor (“getter”) methods – methods with the special purpose of returning object information without violating encapsulation ◦ Returned values are typically already known – the method only needs to return an independent copy of instance data  Mutator (“setter”) methods – methods with the special purpose of updating object state without violating encapsulation ◦ Changing data takes the form of a request, rather than a demand – the object has the opportunity to validate input and enforce its own rules about updating its state