EECS 1001 and EECS 1030M, lab 01 conflict

Similar documents
Chapter 6: Inheritance

CISC 3115 TY3. C09a: Inheritance. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 9/20/2018 CUNY Brooklyn College

Programming for Mobile Computing

CSE 113 A. Announcements - Lab

Inheritance. Lecture 11 COP 3252 Summer May 25, 2017

Administrivia. IBM Info Session Date: Wed,, Jan 13 Time: 5:30 7 pm Location: Wesbrook 100

CSE115 / CSE503 Introduction to Computer Science I. Dr. Carl Alphonce 343 Davis Hall Office hours:

Exam Duration: 2hrs and 30min Software Design

Media Computation. Lecture 16.1, December 8, 2008 Steve Harrison

Programming for Mobile Computing

Programs as Models. Procedural Paradigm. Class Methods. CS256 Computer Science I Kevin Sahr, PhD. Lecture 11: Objects

Computer Science 210: Data Structures

Implementing non-static features

52 Franck van Breugel and Hamzeh Roumani

What is Inheritance?

COS226 - Spring 2018 Class Meeting # 13 March 26, 2018 Inheritance & Polymorphism

Computer Science II (20073) Week 1: Review and Inheritance

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub

Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013

Programming Languages and Techniques (CIS120)

Today. Book-keeping. Inheritance. Subscribe to sipb-iap-java-students. Slides and code at Interfaces.

Objectives for this class meeting. 1. Conduct review of core concepts concerning contracts and pre/post conditions

EECS168 Exam 3 Review

Slide 1 CS 170 Java Programming 1

Programming Exercise 14: Inheritance and Polymorphism

Inheritance, Polymorphism and the Object Memory Model

Who we are: Lecture 1: Overview & Java. Why CS 62? Sample Problems. CS 62 Fall 2016 Kim Bruce & Peter Mawhorter

TOPIC 12 CREATING CLASSES PART 1

CS-202 Introduction to Object Oriented Programming

ITI Introduction to Computing II

For this section, we will implement a class with only non-static features, that represents a rectangle

Chapter 4 Defining Classes I

Abstract Class. Lecture 21. Based on Slides of Dr. Norazah Yusof

Outline. Inheritance. Abstract Classes Interfaces. Class Extension Overriding Methods Inheritance and Constructors Polymorphism.

ITI Introduction to Computing II

EECS 1001 and EECS 1030, lab 01 Conflict

CS-140 Fall 2017 Test 1 Version Practice Practice for Nov. 20, Name:

CO Java SE 8: Fundamentals

CH. 2 OBJECT-ORIENTED PROGRAMMING

Keyword this. Can be used by any object to refer to itself in any class method Typically used to

Lesson 10B Class Design. By John B. Owen All rights reserved 2011, revised 2014

Object Class. EX: LightSwitch Class. Basic Class Concepts: Parts. CS257 Computer Science II Kevin Sahr, PhD. Lecture 5: Writing Object Classes

COMP 110/L Lecture 19. Kyle Dewey

CSE115 Lab 4 Fall 2016

INHERITANCE. Spring 2019

IST311. Advanced Issues in OOP: Inheritance and Polymorphism

Binghamton University. CS-140 Fall Chapter 9. Inheritance

The class Object. Lecture CS1122 Summer 2008

Lecture 1: Overview & Intro to Java

Cpt S 122 Data Structures. Course Review Midterm Exam # 2

Paytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value

Inheritance and Interfaces

Java Object Oriented Design. CSC207 Fall 2014

CS1150 Principles of Computer Science Objects and Classes

BIT 115: Introduction To Programming LECTURE 3. Instructor: Craig Duckett

Chapter 11 Inheritance and Polymorphism. Motivations. Suppose you will define classes to model circles,

Chapter 4. Defining Classes I

Programming for Mobile Computing

CSE 8B Programming Assignments Spring Programming: You will have 5 files all should be located in a dir. named PA3:

CSE115 Lab 2 Fall 2016

Unit3: Java in the large. Prepared by: Dr. Abdallah Mohamed, AOU-KW

Chapter 11: Create Your Own Objects

Object-Oriented Programming

Distributed Systems Recitation 1. Tamim Jabban

Inheritance and Polymorphism

CISC 3130 Data Structures Fall 2018

25. Generic Programming

Java Fundamentals (II)

Chapter 7. Inheritance

CS/ENGRD 2110 SPRING Lecture 7: Interfaces and Abstract Classes

Everything is an object. Almost, but all objects are of type Object!

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

Inheritance, and Polymorphism.

Java Primer 1: Types, Classes and Operators

Chapter 15: Object Oriented Programming

Class, Variable, Constructor, Object, Method Questions

Computer Science II (20082) Week 1: Review and Inheritance

ECE 122. Engineering Problem Solving with Java

Inheritance (Part 2) Notes Chapter 6

9/10/2018 Programming Data Structures Inheritance

Lesson 10A OOP Fundamentals. By John B. Owen All rights reserved 2011, revised 2014

CS 112 Programming 2. Lecture 10. Abstract Classes & Interfaces (1) Chapter 13 Abstract Classes and Interfaces

CS/ENGRD 2110 SPRING Lecture 2: Objects and classes in Java

Carleton University COMP1406/1006, Summer 2013 Tutorial 2

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson

Principles of Software Construction: Objects, Design and Concurrency. Packages and Polymorphism. toad Fall 2012

Comp 249 Programming Methodology Chapter 8 - Polymorphism

Chapter 10 Inheritance and Polymorphism. Dr. Hikmat Jaber

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.

CS 106 Introduction to Computer Science I

Lecture Notes Chapter #9_b Inheritance & Polymorphism

Programming Languages and Techniques (CIS120)

Spring 2003 Instructor: Dr. Shahadat Hossain. Administrative Matters Course Information Introduction to Programming Techniques

Inheritance. Transitivity

CS-140 Fall 2018 Test 2 Version A Nov. 12, Name:

Practice for Chapter 11

Software and Programming 1

Introduction to OOP with Java. Instructor: AbuKhleif, Mohammad Noor Sep 2017

Assignment 3: Inheritance

2. [20] Suppose we start declaring a Rectangle class as follows:

Transcription:

EECS 1001 and EECS 1030M, lab 01 conflict Those students who are taking EECS 1001 and who are enrolled in lab 01 of EECS 1030M should switch to lab 02. If you need my help with switching lab sections, please let me know.

Office hours In LAS 3046: Mondays, 16:30-17:20 and Thursdays, 13:30-14:20 In the lab: Wednesdays, 16:00-17:20, Thursdays, 14:30-15:50 (in the weeks there are no tests scheduled) By appointment (send me email)

Test 1 When: next week, during your lab What: Chapter 2, excluding Section 2.6 Type of questions: similar to the questions of the Quiz on Monday, plus one more challenging question Textbook: study it, since studying just the slides might not be enough Lab: attend the lab in which you are officially enrolled so that we can ensure that there is a computer for everyone

Chapter 3: Implementing Non-Static Features EECS 1030 moodle.yorku.ca

Implementing non-static features Problem Implement the Rectangle class.

Phase 1: analysis Study the API carefully.

Phase 1: analysis Study the API carefully. The methods equals and hashcode and tostring are called obligatory methods. Why?

Phase 1: analysis Study the API carefully. The methods equals and hashcode and tostring are called obligatory methods. Why? Answer Because the Object class contains these methods and, therefore, each class has them (either inherits them or overrides them).

Let s be a client Write an app that creates a Rectangle with width 1 and height 2, prints the rectangle, scales the rectangle by a factor 2, and prints the rectangle again.

Memory diagram Draw the memory diagram representing memory after the rectangle has been printed for the first time.

Invocation of a static method When executing Math.sqrt(2), how many pieces of data are passed to the method invocation?

Invocation of a static method When executing Math.sqrt(2), how many pieces of data are passed to the method invocation? Answer One, namely the value 2.

Invocation of a static method When executing Math.sqrt(2), how many pieces of data are passed to the method invocation? Answer One, namely the value 2. Draw the invocation block for Math.sqrt(2).

Invocation of a non-static method When executing rectangle.scale(2), how many pieces of data are passed to the method invocation?

Invocation of a non-static method When executing rectangle.scale(2), how many pieces of data are passed to the method invocation? Answer Two, namely the value 2 and the value of the object reference rectangle.

this When executing rectangle.scale(2), two arguments are passed to the method invocation. The scale method has only one (explicit) parameter, called factor. The other parameter is implicit and is called this.

this When executing rectangle.scale(2), two arguments are passed to the method invocation. The scale method has only one (explicit) parameter, called factor. The other parameter is implicit and is called this. Draw the invocation block for rectangle.scale(2).

this What is this?

this What is this? Answer A Java keyword and an implicit parameter of non-static methods and constructors.

this What is this? Answer A Java keyword and an implicit parameter of non-static methods and constructors. What does this capture?

this What is this? Answer A Java keyword and an implicit parameter of non-static methods and constructors. What does this capture? Answer A reference to the object on which the method/constructor is invoked.

Structure of a class \\ package statement \\ import statements public class ClassName { \\ attributes \\ constructors } \\ methods

Attributes Does the API of the Rectangle class contain any public attributes?

Attributes Does the API of the Rectangle class contain any public attributes? Answer No.

Attributes Does the API of the Rectangle class contain any public attributes? Answer No. Should the Rectangle class contain any attributes?

Attributes Does the API of the Rectangle class contain any public attributes? Answer No. Should the Rectangle class contain any attributes? Answer Yes, because the state of a rectangle should contain the width and height of the rectangle. All attributes of the Rectangle class are private.

Attributes Which private attributes do we introduce to capture the state of a rectangle? Provide both its type and a descriptive name.

Attributes Which private attributes do we introduce to capture the state of a rectangle? Provide both its type and a descriptive name. Answer width : int height : int

Attributes Could the width and height of a rectangle be represented differently?

Attributes Could the width and height of a rectangle be represented differently? Answer Yes. The state of a rectangle with width 1 and height 2 can be represented, for example, as the String 1-2 and as the long 4294967298 = 1 2 32 + 2.

Initialize the state Where do we initialize the state of an object?

Initialize the state Where do we initialize the state of an object? Answer In the constructor.

Memory diagrams int width = 1; int height = 2; Rectangle rectangle = new Rectangle(width, height); 0. 8 main invocation. width height rectangle

Memory diagrams int width = 1; int height = 2; Rectangle rectangle = new Rectangle(width, height); 0. 8 main invocation 1 width 2 height rectangle.

Memory diagrams int width = 1; int height = 2; Rectangle rectangle = new Rectangle(width, height); 0. 8 main invocation 1 width 2 height rectangle. 48 Rectangle class. 94 Rectangle object. width height

Memory diagrams 0 int width = 1; int height = 2; Rectangle rectangle = new Rectangle(width, height); moodle.yorku.ca EECS. 1030. 8 main invocation 1 width 2 height rectangle. 48 Rectangle class. 94 Rectangle object. width height constructor invocation 94 this 1 width 2 height