COE318 Lecture Notes Week 3 (Sept 19, 2011)
|
|
- Josephine Dixon
- 5 years ago
- Views:
Transcription
1 COE318 Lecture Notes: Week 3 1 of 8 COE318 Lecture Notes Week 3 (Sept 19, 2011) Topics Announcements TurningRobot example PersonAge example Announcements The submit command now works. Quiz: Monday October 3, 2011 Generating javadocs from netbeans is broken (on all platforms). I have reported this problem to netbeans. (Generating javadocs does work if you have a package which we have not yet examined in this course.) To submit from home install the secure shell software on your machine as described in the Department's Network Users Guide. Then: Create a zip file (important note to Windows users: ensure that it is compressed to a.zip file not an.rar file!) Copy the zip file to the Departmental network. Open a remote terminal to the Departmental machine and run the submit command. (You must run this command in the same folder that you copied your zip file to.) Review What is a class/object? The class file source code provides the template or blueprint for creating and using objects of the class type and consists of: instance variables: These correspond to the characteristics of the object. They are declared giving each a name and data type. They are usually private. Instance variables can be used in
2 COE318 Lecture Notes: Week 3 2 of 8 any method or constructor code. Constructors: They are used to perform any initialization needed when creating an object. Although they look like methods, they are different in that they have no return type and must have the same name as the class. Methods: These provide behavior to objects. They must hava a return type (void if nothing is returned) If they are part of the class design, they must be public. Helper methods or others that are not part of the public design should be private. Other details The? Operator Format: <boolean-expression>? <A> : <B> where A and B are expressions of the same type. The value of the expression is A if the boolean-expression is true and B if it is false. Example:.class and.java files int i, j, max; max = i > j? i : j; The jave source code language for a class must have the same name as the class and the extension.java. For example, the source code for the Robot class is in a file called Robot.java. (Note that case is important! Class names should begin with an uppercase letter.) When the source code is compiled, the compilation result is placed in a file with the same name as the class but with the extension.class instead of.java. Example: the TurningRobot class In this example, the robot responds tot the commands left, right, up and down Ii.e. It has methods left() etc. As before. However, a TurningRobot can only move forwards; it cannot move sideways or backwards. But it can turn 90 counter clockwise. For example, if a TurningRobot is moving right and is then asked to move left it has to rotate
3 COE318 Lecture Notes: Week 3 3 of to make its forward direction left. Like a Robot object, a TurningRobot has to know its position (the x and y instance variables). In addition, it has to know its current direction. New Java features used: the switch statement local variables (dir in printdirection) helper private methods public class TurningRobot { //Instance variables private int direction = 0; private int x = 0; private int y = 0; public void right() { setdirection(0); x++; step(); public void up() { setdirection(1); y++; step(); public void left() { setdirection(2); x--; step(); public void down() { setdirection(3); y--; step(); private void setdirection(int desired) { while (desired!= direction) { turn();
4 COE318 Lecture Notes: Week 3 4 of 8 private void turn() { direction++; if (direction == 4) { direction = 0; printdirection(); dir); ", " + private void printdirection() { String dir; switch (direction) { case 0: dir = "right"; break; case 1: dir = "up"; break; case 2: dir = "left"; break; case 3: dir = "down"; break; default: dir = "???"; System.out.println("Turned to move " + private void step() { System.out.println("Stepping to (" + x + y + ")"); Example: the AgePerson class
5 COE318 Lecture Notes: Week 3 5 of 8 This example shows how a AgePerson object can be immutable. (Age changes with time, of course, but age does not have to be an instance variable; if it were, the object would be mutable.) The trick is to use Date of Birth as an instance variable. The getage() method then calculates the age at the present time. Note: You are not responsible for knowing about the Calendar or GregorianCalendar classes. import java.util.calendar; import java.util.gregoriancalendar; public class PersonAge { private Calendar dob; private String name; public PersonAge(String n, Calendar d) { name = n; dob = d; public String getname() { return name; public int getage() { Calendar today = new GregorianCalendar(); int yearnow = today.get(calendar.year); int birthyear = dob.get(calendar.year); int age = yearnow - birthyear; if (today.get(calendar.day_of_year) < dob.get(calendar.day_of_year)) { age--; return age; Data types There are 2 general data types:
6 COE318 Lecture Notes: Week 3 6 of 8 1. primitive, and 2. reference Primitive data types are int, float, double, short, long, byte, boolean and char. When a primitive data type is declared, the memory required to hold the data is allocated and that memory contains the value of the data. For example, the declaration byte i; allocates one byte of memory for the variable i. The assignment statement i = 5; would set that memory location's value to 5. Every class (and there are thousands built into the java library) is also a data type. But it is a reference data type. The reference points to an area in memory where the actual object of the type resides. The most common built-in reference data type is String. When a reference data type is declared, memory is set aside to hold the reference. This is always 4 bytes no matter how big the actual data object is. The reference is instantiated by assigning it to an object (which may need to be created) of the correct data type. For example: Robot robbie; robbie = new Robot(); An actual Robot object is created with new Robot() (which invokes the Robot class's constructor) and it resides somewhere in memory (and uses many more than 4 bytes!). The reference value robbie points to the starting address of the actual Robot object. The place in memory where objects exist is called the heap. The Java Virtual Machine (JVM) keeps track of how many references there are to objects in the heap. When the reference count becomes zero, it is no longer possible to access the object. It has become garbage. The JVM periodically runs a Garbage Collector which frees up the space occupied by garbage objects. Where variable names are used Variable names can be used for instance variables, parameter names and local variables. Instance variables are declared in a class body. They can be accessed by any method of the class. They are usually public. Parameter names are the arbitrary names given to the passed parameters of methods or constructors. Parameters only exist during the execution of the method or constructor and cannot be seen by other methods. (If 2 methods have the same name for a parameter, no interference results.)
7 COE318 Lecture Notes: Week 3 7 of 8 If a parameter name and an instance variable name are the same, the name all by itself refers to the paramter. To access the instance variable of the same name, use this.name. Local variables are declared and used inside methods. They only exist during the execution of the method. To be even more specific, on entry to a method, space for all the local variables is allocated on the stack. Questions 1. Given the two classes, A and B, shown below identify identify each as mutable or immutable. Explain. public class A { private final int p; public int q; public A(int p, int q) { this.p = p; this.q = q; public int getp() { return p; public int getq() { return q; public class B { private final int x; private int y; public B(int x, int y) { this.x = x; this.y = y;
8 COE318 Lecture Notes: Week 3 8 of 8 /** the x */ public int getx() { return x; /** the y */ public int gety() { return y;
COE318 Lecture Notes Week 4 (Sept 26, 2011)
COE318 Software Systems Lecture Notes: Week 4 1 of 11 COE318 Lecture Notes Week 4 (Sept 26, 2011) Topics Announcements Data types (cont.) Pass by value Arrays The + operator Strings Stack and Heap details
More informationCOE318 Lecture Notes Week 3 (Week of Sept 15, 2014)
COE318 Lecture Notes: Week 3 1 of 17 COE318 Lecture Notes Week 3 (Week of Sept 15, 2014) Announcements (REPEAT!) Quiz (5% of total mark) on Wednesday, September 24, 2014. Covers weeks 1 3 and labs 1 3.
More informationCOE318 Lecture Notes Week 3 (Week of Sept 17, 2012)
COE318 Lecture Notes: Week 3 1 of 8 COE318 Lecture Notes Week 3 (Week of Sept 17, 2012) Announcements Quiz (5% of total mark) on Wednesday, September 26, 2012. Covers weeks 1 3. This includes both the
More informationCOE318 Lecture Notes Week 5 (Oct 3, 2011)
COE318 Software Systems Lecture Notes: Week 5 1 of 6 COE318 Lecture Notes Week 5 (Oct 3, 2011) Topics Announcements Strings static and final qualifiers Stack and Heap details Announcements Quiz: Today!
More informationCOE318 Lecture Notes Week 6 (Oct 10, 2011)
COE318 Software Systems Lecture Notes: Week 6 1 of 8 COE318 Lecture Notes Week 6 (Oct 10, 2011) Topics Announcements final qualifiers Example: An alternative to arrays == vs..equals(...): A first look
More informationRemedial classes. G51PRG: Introduction to Programming Second semester Lecture 2. Plan of the lecture. Classes and Objects. Example: Point class
G51PRG: Introduction to Programming Second semester Lecture 2 Remedial classes Monday 3-5 in A32 Contact Yan Su (yxs) Ordinary labs start on Tuesday Natasha Alechina School of Computer Science & IT nza@cs.nott.ac.uk
More informationJava How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved.
Java How to Program, 10/e Education, Inc. All Rights Reserved. Each class you create becomes a new type that can be used to declare variables and create objects. You can declare new classes as needed;
More information3.1 Class Declaration
Chapter 3 Classes and Objects OBJECTIVES To be able to declare classes To understand object references To understand the mechanism of parameter passing To be able to use static member and instance member
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationUpdates. Office B116E Office Hours : Friday 1 p.m. 2 p.m. Also by appointment Office Hours Purpose:
CS 180 Amit Gupta Updates Office B116E Office Hours : Friday 1 p.m. 2 p.m. Also by appointment gupta75@purdue.edu Office Hours Purpose: Course Material and Recitation No project questions Quizzes I will
More informationCOE318 Lecture Notes Week 8 (Oct 24, 2011)
COE318 Software Systems Lecture Notes: Week 8 1 of 17 COE318 Lecture Notes Week 8 (Oct 24, 2011) Topics == vs..equals(...): A first look Casting Inheritance, interfaces, etc Introduction to Juni (unit
More information7. C++ Class and Object
7. C++ Class and Object 7.1 Class: The classes are the most important feature of C++ that leads to Object Oriented programming. Class is a user defined data type, which holds its own data members and member
More informationVARIABLES AND TYPES CITS1001
VARIABLES AND TYPES CITS1001 Scope of this lecture Types in Java the eight primitive types the unlimited number of object types Values and References The Golden Rule Primitive types Every piece of data
More informationProgramming II (CS300)
1 Programming II (CS300) Chapter 02: Using Objects MOUNA KACEM mouna@cs.wisc.edu Fall 2018 Using Objects 2 Introduction to Object Oriented Programming Paradigm Objects and References Memory Management
More informationJava Classes & Primitive Types
Java Classes & Primitive Types Rui Moreira Classes Ponto (from figgeom) x : int = 0 y : int = 0 n Attributes q Characteristics/properties of classes q Primitive types (e.g., char, byte, int, float, etc.)
More informationJava Classes & Primitive Types
Java Classes & Primitive Types Rui Moreira Classes Ponto (from figgeom) x : int = 0 y : int = 0 n Attributes q Characteristics/properties of classes q Primitive types (e.g., char, byte, int, float, etc.)
More informationObject Oriented Programming: In this course we began an introduction to programming from an object-oriented approach.
CMSC 131: Chapter 28 Final Review: What you learned this semester The Big Picture Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach. Java
More informationJAVA GUI PROGRAMMING REVISION TOUR III
1. In java, methods reside in. (a) Function (b) Library (c) Classes (d) Object JAVA GUI PROGRAMMING REVISION TOUR III 2. The number and type of arguments of a method are known as. (a) Parameter list (b)
More informationChapter 6 Introduction to Defining Classes
Introduction to Defining Classes Fundamentals of Java: AP Computer Science Essentials, 4th Edition 1 Objectives Design and implement a simple class from user requirements. Organize a program in terms of
More informationCE221 Programming in C++ Part 1 Introduction
CE221 Programming in C++ Part 1 Introduction 06/10/2017 CE221 Part 1 1 Module Schedule There are two lectures (Monday 13.00-13.50 and Tuesday 11.00-11.50) each week in the autumn term, and a 2-hour lab
More informationOutline. Object Oriented Programming. Course goals. Staff. Course resources. Assignments. Course organization Introduction Java overview Autumn 2003
Outline Object Oriented Programming Autumn 2003 2 Course goals Software design vs hacking Abstractions vs language (syntax) Java used to illustrate concepts NOT a course about Java Prerequisites knowledge
More informationCOE318 Lecture Notes Week 9 (Week of Oct 29, 2012)
COE318 Lecture Notes: Week 9 1 of 14 COE318 Lecture Notes Week 9 (Week of Oct 29, 2012) Topics The final keyword Inheritance and Polymorphism The final keyword Zoo: Version 1 This simple version models
More informationIntroduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview
Introduction to Visual Basic and Visual C++ Introduction to Java Lesson 13 Overview I154-1-A A @ Peter Lo 2010 1 I154-1-A A @ Peter Lo 2010 2 Overview JDK Editions Before you can write and run the simple
More informationC10: Garbage Collection and Constructors
CISC 3120 C10: Garbage Collection and Constructors Hui Chen Department of Computer & Information Science CUNY Brooklyn College 3/5/2018 CUNY Brooklyn College 1 Outline Recap OOP in Java: composition &
More informationJava Identifiers, Data Types & Variables
Java Identifiers, Data Types & Variables 1. Java Identifiers: Identifiers are name given to a class, variable or a method. public class TestingShastra { //TestingShastra is an identifier for class char
More informationProgramming for Mobile Computing
1/57 Programming for Mobile Computing EECS 1022 moodle.yorku.ca Labs 2/57 For the things we have to learn before we can do them, we learn by doing them. Aristotle During the labs, carefully read the instructions,
More informationOutline. Review of Last Week II. Review of Last Week. Computer Memory. Review Variables and Memory. February 7, Data Types
Data Types Declarations and Initializations Larry Caretto Computer Science 16 Computing in Engineering and Science February 7, 25 Outline Review last week Meaning of data types Integer data types have
More informationProgramming Language Concepts: Lecture 2
Programming Language Concepts: Lecture 2 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in http://www.cmi.ac.in/~madhavan/courses/pl2011 PLC 2011, Lecture 2, 6 January 2011 Classes and
More informationProgramming II (CS300)
1 Programming II (CS300) Chapter 03: Creating Classes MOUNA KACEM mouna@cs.wisc.edu Spring 2019 Creating Classes 2 Constructors and Object Initialization Static versus non-static fields/methods Encapsulation
More informationCHAPTER 7 OBJECTS AND CLASSES
CHAPTER 7 OBJECTS AND CLASSES OBJECTIVES After completing Objects and Classes, you will be able to: Explain the use of classes in Java for representing structured data. Distinguish between objects and
More informationProgramming II (CS300)
1 Programming II (CS300) Chapter 03: Creating Classes MOUNA KACEM mouna@cs.wisc.edu Spring 2018 Creating Classes 2 Constructors and Object Initialization Static versus non-static fields/methods Encapsulation
More informationProgramming Languages and Techniques (CIS120)
Programming Languages and Techniques (CIS120) Lecture 21 March 12, 2018 Java: Objects, Interfaces, Static Members Chapters 19 & 20 Announcements Java Bootcamp Tonight!! Towne 100, 6-8 pm HW06: Pennstagram
More informationData Structures. Data structures. Data structures. What is a data structure? Simple answer: a collection of data equipped with some operations.
Data Structures 1 Data structures What is a data structure? Simple answer: a collection of data equipped with some operations. Examples Lists Strings... 2 Data structures In this course, we will learn
More informationComputer Science II Data Structures
Computer Science II Data Structures Instructor Sukumar Ghosh 201P Maclean Hall Office hours: 10:30 AM 12:00 PM Mondays and Fridays Course Webpage homepage.cs.uiowa.edu/~ghosh/2116.html Course Syllabus
More informationObject-Oriented Programming Concepts
Object-Oriented Programming Concepts Object-oriented programming מונחה עצמים) (תכנות involves programming using objects An object ) represents (עצם an entity in the real world that can be distinctly identified
More informationChapter 4 Java Language Fundamentals
Chapter 4 Java Language Fundamentals Develop code that declares classes, interfaces, and enums, and includes the appropriate use of package and import statements Explain the effect of modifiers Given an
More informationFall 2017 CISC124 9/16/2017
CISC124 Labs start this week in JEFF 155: Meet your TA. Check out the course web site, if you have not already done so. Watch lecture videos if you need to review anything we have already done. Problems
More informationProgramming Languages and Techniques (CIS120)
Programming Languages and Techniques (CIS120) Lecture 26 March 26, 2015 Inheritance and Dynamic Dispatch Chapter 24 public interface Displaceable { public int getx(); public int gety(); public void move
More informationObject Oriented Programming and Design in Java. Session 2 Instructor: Bert Huang
Object Oriented Programming and Design in Java Session 2 Instructor: Bert Huang Announcements TA: Yipeng Huang, yh2315, Mon 4-6 OH on MICE clarification Next Monday's class canceled for Distinguished Lecture:
More informationChapter 6 Classes and Objects
Chapter 6 Classes and Objects Hello! Today we will focus on creating classes and objects. Now that our practice problems will tend to generate multiple files, I strongly suggest you create a folder for
More informationAgenda CS121/IS223. Reminder. Object Declaration, Creation, Assignment. What is Going On? Variables in Java
CS121/IS223 Object Reference Variables Dr Olly Gotel ogotel@pace.edu http://csis.pace.edu/~ogotel Having problems? -- Come see me or call me in my office hours -- Use the CSIS programming tutors Agenda
More informationLecture 3. Lecture
True Object-Oriented programming: Dynamic Objects Static Object-Oriented Programming Reference Variables Eckel: 30-31, 41-46, 107-111, 114-115 Riley: 5.1, 5.2 D0010E Object-Oriented Programming and Design
More informationScala. Introduction. Scala
Scala Introduction 1 Scala Scala was proposed by Professor Martin Odersky and his group at EPFL in 2003 to provide a highperformance, concurrent-ready environment for functional programming and object-oriented
More informationAssumptions. History
Assumptions A Brief Introduction to Java for C++ Programmers: Part 1 ENGI 5895: Software Design Faculty of Engineering & Applied Science Memorial University of Newfoundland You already know C++ You understand
More informationC11: Garbage Collection and Constructors
CISC 3120 C11: Garbage Collection and Constructors Hui Chen Department of Computer & Information Science CUNY Brooklyn College 10/5/2017 CUNY Brooklyn College 1 Outline Recap Project progress and lessons
More informationCS121/IS223. Object Reference Variables. Dr Olly Gotel
CS121/IS223 Object Reference Variables Dr Olly Gotel ogotel@pace.edu http://csis.pace.edu/~ogotel Having problems? -- Come see me or call me in my office hours -- Use the CSIS programming tutors CS121/IS223
More informationOutline. Java Models for variables Types and type checking, type safety Interpretation vs. compilation. Reasoning about code. CSCI 2600 Spring
Java Outline Java Models for variables Types and type checking, type safety Interpretation vs. compilation Reasoning about code CSCI 2600 Spring 2017 2 Java Java is a successor to a number of languages,
More information2. The object-oriented paradigm!
2. The object-oriented paradigm! Plan for this section:! n Look at things we have to be able to do with a programming language! n Look at Java and how it is done there" Note: I will make a lot of use of
More informationCS 251 Intermediate Programming Methods and Classes
CS 251 Intermediate Programming Methods and Classes Brooke Chenoweth University of New Mexico Fall 2018 Methods An operation that can be performed on an object Has return type and parameters Method with
More informationCS 251 Intermediate Programming Methods and More
CS 251 Intermediate Programming Methods and More Brooke Chenoweth University of New Mexico Spring 2018 Methods An operation that can be performed on an object Has return type and parameters Method with
More informationECE 122. Engineering Problem Solving with Java
ECE 122 Engineering Problem Solving with Java Lecture 5 Anatomy of a Class Outline Problem: How do I build and use a class? Need to understand constructors A few more tools to add to our toolbox Formatting
More informationZhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson
Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson Introduction History, Characteristics of Java language Java Language Basics Data types, Variables, Operators and Expressions Anatomy of a Java Program
More informationProgramming Languages and Techniques (CIS120)
Programming Languages and Techniques (CIS120) Lecture 36 April 23, 2014 Overriding and Equality HW 10 has a HARD deadline Announcements You must submit by midnight, April 30 th Demo your project to your
More informationProgramming Languages and Techniques (CIS120)
Programming Languages and Techniques (CIS120) Lecture 22 March 14 th, 2016 Object Oriented Programming in Java Java Bootcamp tonight Announcements Monday, March 14 from 6-8pm in Levine 101 (Wu & Chen)
More informationDomain-Driven Design Activity
Domain-Driven Design Activity SWEN-261 Introduction to Software Engineering Department of Software Engineering Rochester Institute of Technology Entities and Value Objects are special types of objects
More informationProgramming Languages and Techniques (CIS120)
Programming Languages and Techniques (CIS120) Lecture 37 April 22, 2016 Encapsulation & Hashing How is the Game Project going so far? 1. not started 2. got an idea 3. submitted design proposal 4. started
More informationJAVA MOCK TEST JAVA MOCK TEST II
http://www.tutorialspoint.com JAVA MOCK TEST Copyright tutorialspoint.com This section presents you various set of Mock Tests related to Java Framework. You can download these sample mock tests at your
More informationProgramming Languages and Techniques (CIS120)
Programming Languages and Techniques (CIS120) Lecture 28 March 30, 2016 Collections and Equality Chapter 26 Announcements Dr. Steve Zdancewic is guest lecturing today He teaches CIS 120 in the Fall Midterm
More informationComputational Expression
Computational Expression Variables, Primitive Data Types, Expressions Janyl Jumadinova 28-30 January, 2019 Janyl Jumadinova Computational Expression 28-30 January, 2019 1 / 17 Variables Variable is a name
More informationcoe318 Lab 1 Introduction to Netbeans and Java
coe318 Lab 1 Week of September 12, 2016 Objectives Lean how to use the Netbeans Integrated Development Environment (IDE). Learn how to generate and write formatted API documentation. Add a constructor,
More informationCompiling Techniques
Lecture 10: Introduction to 10 November 2015 Coursework: Block and Procedure Table of contents Introduction 1 Introduction Overview Java Virtual Machine Frames and Function Call 2 JVM Types and Mnemonics
More informationProgramming Languages and Techniques (CIS120)
Programming Languages and Techniques (CIS120) Lecture 25 March 18, 2013 Subtyping and Dynamic Dispatch Announcements HW07 due tonight at midnight Weirich OH cancelled today Help your TAs make the most
More informationProgramming Languages and Techniques (CIS120)
Programming Languages and Techniques (CIS120) Lecture 24 March 18, 2016 The Java ASM What is the value of ans at the end of this program? Counter[] a = { new Counter(), new Counter() ; Counter[] b = {
More informationJava Application Development
In order to learn which questions have been answered correctly: 1. Print these pages. 2. Answer the questions. 3. Send this assessment with the answers via: a. FAX to (212) 967-3498. Or b. Mail the answers
More informationCHAPTER 7 OBJECTS AND CLASSES
CHAPTER 7 OBJECTS AND CLASSES OBJECTIVES After completing Objects and Classes, you will be able to: Explain the use of classes in Java for representing structured data. Distinguish between objects and
More informationBBM 102 Introduction to Programming II Spring 2017
BBM 102 Introduction to Programming II Spring 2017 Classes and Objects in Java Instructors: Ayça Tarhan, Fuat Akal, Gönenç Ercan, Vahid Garousi TAs: Selma Dilek, Selim Yılmaz, Selman Bozkır 1 Today Defining
More informationC++ (classes) Hwansoo Han
C++ (classes) Hwansoo Han Inheritance Relation among classes shape, rectangle, triangle, circle, shape rectangle triangle circle 2 Base Class: shape Members of a class Methods : rotate(), move(), Shape(),
More informationLecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University
Lecture 3 COMP1006/1406 (the Java course) Summer 2014 M. Jason Hinek Carleton University today s agenda assignments 1 (graded) & 2 3 (available now) & 4 (tomorrow) a quick look back primitive data types
More informationReview questions. Review questions, cont d. Class Definition. Methods. Class definition: methods. April 1,
April 1, 2003 1 Previous Lecture: Intro to OOP Class definition: instance variables & methods Today s Lecture: Instance methods Constructors Methods with input parameters Review questions Where do you
More informationObjects and Classes: Working with the State and Behavior of Objects
Objects and Classes: Working with the State and Behavior of Objects 1 The Core Object-Oriented Programming Concepts CLASS TYPE FACTORY OBJECT DATA IDENTIFIER Classes contain data members types of variables
More informationChapter 5 Names, Bindings, Type Checking, and Scopes
Chapter 5 Names, Bindings, Type Checking, and Scopes Names Variables The Concept of Binding Scope and Lifetime Type Checking Referencing Environments Named Constants Names Used for variables, subprograms
More information1B1b. Classes in Java Part III. Review. Static. Static (2) Example. Static (3) 1B1b Lecture Slides. Copyright 2004, Graham Roberts 1
1B1b Classes in Java Part III Review We have seen that classes: declare instance variables. declare methods. may have constructors. Now want to start filling in further details. 1 2 Static Why are some
More informationEECS1710. Announcements. Labtests have been returned Term Test #01 marking is in progress. Next Labtest: Thu Oct 23/Fri Oct 24
EECS1710 Click to edit Master Week text 05, styles Lecture 10 Second level Third level Fourth level Fifth level Fall 2014! Thursday, Oct 09, 2014 1 Announcements Labtests have been returned Term Test #01
More informationCSE 142 Su 04 Computer Programming 1 - Java. Objects
Objects Objects have state and behavior. State is maintained in instance variables which live as long as the object does. Behavior is implemented in methods, which can be called by other objects to request
More informationProgramming Languages and Techniques (CIS120)
Programming Languages and Techniques (CIS120) Lecture 25 November 1, 2017 Inheritance and Dynamic Dispatch (Chapter 24) Announcements HW7: Chat Client Available Soon Due: Tuesday, November 14 th at 11:59pm
More informationShort Notes of CS201
#includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system
More informationTHE CONCEPT OF OBJECT
THE CONCEPT OF OBJECT An object may be defined as a service center equipped with a visible part (interface) and an hidden part Operation A Operation B Operation C Service center Hidden part Visible part
More informationLecture 06: Classes and Objects
Accelerating Information Technology Innovation http://aiti.mit.edu Lecture 06: Classes and Objects AITI Nigeria Summer 2012 University of Lagos. What do we know so far? Primitives: int, float, double,
More informationPROGRAMMING FUNDAMENTALS
PROGRAMMING FUNDAMENTALS Q1. Name any two Object Oriented Programming languages? Q2. Why is java called a platform independent language? Q3. Elaborate the java Compilation process. Q4. Why do we write
More informationCSE115 / CSE503 Introduction to Computer Science I. Dr. Carl Alphonce 343 Davis Hall Office hours:
CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu Office hours: Thursday 12:00 PM 2:00 PM Friday 8:30 AM 10:30 AM OR request appointment via e-mail
More informationCSC207 Week 2. Larry Zhang
CSC207 Week 2 Larry Zhang 1 Today s Outline Finish up non-oo examples, Array, HashMap OO programming Unit Test: JUnit (if time permits) Javadoc (if time permits) 2 Recap Java code is compiled into bytecode
More informationTaxiBot New attributes Variables Math! TaxiBot
TaxiBot New attributes Variables Math! TaxiBot TaxiBot operates in the city BUT it charges you for its actions TaxiBot extends RobotSE TaxiBot displays how much is owed 1 TaxiBot charges Moving 1 space
More informationProgramming Languages and Techniques (CIS120)
Programming Languages and Techniques (CIS120) Lecture 24 October 29, 2018 Arrays, Java ASM Chapter 21 and 22 Announcements HW6: Java Programming (Pennstagram) Due TOMORROW at 11:59pm Reminder: please complete
More informationCS321 Languages and Compiler Design I. Winter 2012 Lecture 2
CS321 Languages and Compiler Design I Winter 2012 Lecture 2 1 A (RE-)INTRODUCTION TO JAVA FOR C++/C PROGRAMMERS Why Java? Developed by Sun Microsystems (now Oracle) beginning in 1995. Conceived as a better,
More informationDay 6. COMP1006/1406 Summer M. Jason Hinek Carleton University
Day 6 COMP1006/1406 Summer 2016 M. Jason Hinek Carleton University today s agenda assignments Assignment 3 is due on Monday a quick look back abstract classes and interfaces casting objects abstract data
More informationCS 520 Theory and Practice of Software Engineering Fall 2017
CS 520 Theory and Practice of Software Engineering Fall 2017 Best and worst programming practices September 12, 2017 Logistics Recap: software architecture vs. design Specification Architecture Development
More informationExam 1 Prep. Dr. Demetrios Glinos University of Central Florida. COP3330 Object Oriented Programming
Exam 1 Prep Dr. Demetrios Glinos University of Central Florida COP3330 Object Oriented Programming Progress Exam 1 is a Timed Webcourses Quiz You can find it from the "Assignments" link on Webcourses choose
More informationAn Introduction to C++
An Introduction to C++ Introduction to C++ C++ classes C++ class details To create a complex type in C In the.h file Define structs to store data Declare function prototypes The.h file serves as the interface
More informationCS201 - Introduction to Programming Glossary By
CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with
More informationRecommended Group Brainstorm (NO computers during this time)
Recommended Group Brainstorm (NO computers during this time) Good programmers think before they begin coding. Part I of this assignment involves brainstorming with a group of peers with no computers to
More informationLecture 8 Classes and Objects Part 2. MIT AITI June 15th, 2005
Lecture 8 Classes and Objects Part 2 MIT AITI June 15th, 2005 1 What is an object? A building (Strathmore university) A desk A laptop A car Data packets through the internet 2 What is an object? Objects
More informationCS-140 Fall 2017 Test 1 Version Practice Practie for Sept. 27, Name:
CS-140 Fall 2017 Test 1 Version Practice Practie for Sept. 27, 2017 Name: 1. (10 points) For the following, Check T if the statement is true, the F if the statement is false. (a) T F : In mathematics,
More informationCS360 Lecture 5 Object-Oriented Concepts
Tuesday, February 17, 2004 Last Time CS360 Lecture 5 Object-Oriented Concepts On Thursday I introduced the basics of object-oriented programming. We covered: - Creating public classes (each public class
More informationCS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University
9/5/6 CS Introduction to Computing II Wayne Snyder Department Boston University Today: Arrays (D and D) Methods Program structure Fields vs local variables Next time: Program structure continued: Classes
More informationTwo Types of Types. Primitive Types in Java. Using Primitive Variables. Class #07: Java Primitives. Integer types.
Class #07: Java Primitives Software Design I (CS 120): M. Allen, 13 Sep. 2018 Two Types of Types So far, we have mainly been dealing with objects, like DrawingGizmo, Window, Triangle, that are: 1. Specified
More information1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4. Epic Test Review 5 Epic Test Review 6 Epic Test Review 7 Epic Test Review 8
Epic Test Review 1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4 Write a line of code that outputs the phase Hello World to the console without creating a new line character. System.out.print(
More informationObject Oriented Programming. Week 1 Part 3 Writing Java with Eclipse and JUnit
Object Oriented Programming Part 3 Writing Java with Eclipse and JUnit Today's Lecture Test Driven Development Review (TDD) Building up a class using TDD Adding a Class using Test Driven Development in
More informationcoe318 Lab 2 ComplexNumber objects
Objectives Overview coe318 Lab 2 objects Implement a class. Learn how immutable objects work. Week of September 15, 2014 Create a project with more than one class. Duration: one week. In mathematics, complex
More informationAP Computer Science Chapter 10 Implementing and Using Classes Study Guide
AP Computer Science Chapter 10 Implementing and Using Classes Study Guide 1. A class that uses a given class X is called a client of X. 2. Private features of a class can be directly accessed only within
More informationCOMP 250: Java Programming I. Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette
COMP 250: Java Programming I Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette Variables and types [Downey Ch 2] Variable: temporary storage location in memory.
More information