Advanced Object Oriented Programming. EECS2030 Section A
|
|
- Roger Hugo Pierce
- 5 years ago
- Views:
Transcription
1 Advanced Object Oriented Programming EECS2030 Section A 1
2 Who Am I? Dr. Mufleh Al-Shatnawi office Lassonde 3057 hours : 5:30PM -- 6:30PM on Tuesdays and Thursdays; or by appointments mufleh@eecs.yorku.ca 2
3 Course Format Everything you need to know will eventually be on the York University Moodle site. York course Moodle [ ] Check this site regularly for announcements and learning resources 3
4 Course Description While LE/EECS1020 and LE/EECS1021 focuses on the client concern, this course focuses on the concern of the implementer. Hence, rather than using an API (Application Programming Interface) to build an application, the student is asked to implement a given API. 4
5 Course Description (cont.) Topics include implementing classes (non-utilities, delegation within the class definition, documentation and API generation, implementing contracts), aggregations(implementing aggregates versus compositions and implementing collections), inheritance hierarchies (attribute visibility, overriding methods, abstract classes versus interfaces, inner classes); applications of aggregation and inheritance in concurrent programming and event-driven programming; recursion; searching and sorting including quick and merge sorts; stacks and queues; linked lists; binary trees. 5
6 Prerequisites You must at least have the below prerequisites: LE/EECS or LE/EECS 1020 (prior to Fall 2015) 3.00 or LE/EECS or LE/EECS The General Prerequisite is a cumulative GPA of 4.50 or better over all major EECS courses. 6
7 Lectures One person talks at a time in class, please! Do not use Cell phones during lectures. Attendance to all lectures and labs are necessary. Don t consider coming to classes as pressure. 7
8 Labs In Prism computing labs (LAS1006) Lab Zero starts in Week 1 self-guided, can be done anytime before the start of Week 2 using the Prism lab environment using eclipse Labs (<=8) consist of a different set of programming problems for each lab It is expected that you know how to use the lab computing environment. Fun, hard work, a great learning experience 8
9 Labs Lab Times LAB (Section-01): Tuesdays: 14:30-16:00 (LAS 1006) LAB (Section-02): Thursdays: 14:30-16:00 (LAS 1006) group lab work is allowed and strongly encouraged for Labs (not Lab Zero) groups of up to size 3 see Academic Honesty section of syllabus Do not submit work that is not wholly your own It is absolutely not acceptable that you: share your (programming or written) solutions with others; copy and paste solutions from elsewhere and claim that they are yours. 9
10 Labs Tips for effective group work alternate who is doing the typing (the driver) every few minutes don t allow the stronger programmer to do everything!! if you are the stronger programmer then try explaining your thought processes to your group partners if you aren t typing then you are a navigator you should be: 10 watching what the driver is doing to catch mistakes planning what the group should do next developing test cases to test the code that is being written
11 EECS Account needed for EECS2030 You must at least have a Prism Lab account before starting the course. If you don't have a Prism Lab account for EECS courses, please consult lab monitors at LAS You must have a YoRkU ID card with you at all times. If you don t have the account ready, you cannot do the labs and tests. 11
12 Lab Tests Computer test, based on lab exercises and lecture materials Each lab section has its own lab tests 12
13 Tests All testing occurs during your regularly scheduled lab using the EECS labtest environment Test Weight Lab Test 1 20% Lab Test 2 15% Lab Test 3 15% Exam 40% miss a test for an acceptable reason? see Evaluation: Missed tests section of syllabus 13
14 Textbook Aset of freely available electronic notes is available from the Moodle site Recommended textbooks Building Java Programs, 4 th Edition, S Rogesand M Stepp Introduction to Programming in Java, 2 nd Edition, R Sedgewick and K Wayne does not cover inheritance Absolute Java, 6 th Edition, W Savitch Recommended references Java 8 Pocket Guide,Liguoriand Liguori Effective Java, 3 rd Edition, J Bloch 14
15 Need Accommodation for Tests/Exams? Please approach me ( , in person) as soon as possible, so we can make proper arrangements for you. 15
16 Prepare your own machine Install Java, and Eclipse index.html IDE for Java Developers] 16
17 Organization of a Java Program Packages, classes, fields, and methods 17
18 Organization of a Typical Java Program one or more files 18
19 Organization of a Typical Java Program one or more files zero or one package name 19
20 Organization of a Typical Java Program one or more files zero or one package name zero or more import statements 20
21 Organization of a Typical Java Program one or more files zero or one package name zero or more import statements one class 21
22 Organization of a Typical Java Program one or more files zero or one package name zero or more import statements one class one or more fields (class variables) 22
23 Organization of a Typical Java Program one or more files zero or one package name zero or more import statements one class zero or more fields (class variables) zero or more more constructors 23
24 Organization of a Typical Java Program one or more files zero or one package name zero or more import statements one class zero or more fields (class variables) zero or more more constructors zero or more methods 24
25 Organization of a Typical Java Program it's actually more complicated than this static initialization blocks non-static initialization blocks classes inside of classes (inside of classes...) classes inside of methods anonymous classes lambda expressions (in Java 8) see 25
26 Packages Packages are used to organize Java classes into namespaces we organize files into different directories according to their functionality, usability as well as category they should belong to. A namespace is a container for names the namespace also has a name Hint: Java packages can be stored in compressed files called JAR files. 26
27 Packages Packages are use to organize related classes and interfaces e.g., all of the Java API classes are in the package named java package class directory (folder) file 27
28 Packages Packages can contain subpackages e.g., the package javacontains packages named lang, util, io, etc. The fully qualified name of the subpackageis the fully qualified name of the parent package followed by a period followed by the subpackage name e.g., java.lang, java.util, java.io 28
29 Examples: The Java API javax.swing: classes dealing with the development of GUIs. java.lang: essential classes required by the Java language. java.text: facilities for formatting text output. java.util: classes for storing/accessing collections of objects. java.net: for network communication. 29
30 Packages Packages can contain classes and interfaces e.g., the package java.lang contains the classes Object, String, Math, etc. The fully qualified name of the class is the fully qualified name of the containing package followed by a period followed by the class name e.g., java.lang.object, java.lang.string, java.lang.math 30
31 Packages Packages are supposed to ensure that fully qualified names are unique For example, if we have a class name called "Vector", its name would crash with the Vector class from JDK. However, this never happens because JDK uses java.utilas a package name for the Vector class (java.util.vector ). This allows the compiler to disambiguate classes with the same unqualified name, e.g., your.string s = new your.string("hello"); String t = "hello"; 31
32 Packages How do we ensure that fully qualified names are unique? Package naming convention packages should be organized using your domain name in reverse, e.g., EECS domain name eecs.yorku.ca package name ca.yorku.eecs We might consider putting everything for this course under the following package eecs
33 Packages We might consider putting everything for this course under the following package eecs2030 Labs might be organized into subpackages: eecs2030.lab0 eecs2030.lab1 and so on Tests might be organized into subpackages: eecs2030.test1 eecs2030.test2 and so on 33
34 Packages Most Java implementations assume that your directory structure matches the package structure, e.g., there is a folder eecs2030inside the project srcfolder there is a folder lab0inside the eecs2030folder there is a folder lab1inside the eecs2030folder, and so on 34
35 Packages project folder project sources folder eecs2030 folder lab0 folder To put a class into a package, one uses the "package" statement 35
36 Importing a package import packagename.*; // all classes import packagename.classname;// one class 36
37 Importing a package -Static import import static packagename.classname.*; Example: import static java.lang.math.*;... double angle = sin(pi / 2) + ln(e * E); Static import allows you to refer to themembers of another class without writing that class's name. Should be used rarely and only with classes whose contents are entirely static "utility" code. 37
38 Package access Java provides the following access modifiers: public: Visible to all other classes. private: Visible only to the current class (and any nested types). protected : Visible to the current class, any of its subclasses, and any other types within the same package. default (package): Visible to the current class and any other types within the same package. 38
39 Notes on the import statement Import ONLY imports public classes from the specified package Classes which are not public cannot be referenced from outside their package. There is no way to "import all classes except one" import either imports a single class or all classes within the package Note: importing has no runtime or performance implications. It is only importing a namespace so that the compiler can resolve class names. Import statements must appear at the top of the file after the package statement and before any class or interface definitions. 39
40 Objects in JAVA Basics 40
41 Define Your Own Objects In the previous course, you may have already gained experience in defining your own data structures (a.k.a. data types, objects) that you used within your program in order to group various data elements together. we create this object by defining a class. Each class that we define represents a new type (or category) of object. 41
42 Objects A object represents multiple pieces of information that are grouped together. A primitive data type (e.g., int, float, char) represents a single simple piece of information. An object, however, is a bundle of data, which can be made up of multiple primitives or possibly other objects as well. 42
43 Objects Once we define Address class/object, then we were allowed to create Address objects and use them within our programs. Address addr; addr = new Address(); 2030 addr.name = "EECS Student One"; addr.streetnumber = 2030; addr.streetname = "EECS Department ST"; addr.city = "Tornoro"; addr.province = "ON"; addr.postalcode = "M3J 1P3"; System.out.print(addr.name + " lives at "); System.out.println(addr.streetNumber + " " + addr.streetname); 43
44 Overview An object can contain variables as well as methods. Variable in an object is called a field. Declare fields in the class definition. Generally, make fields privateso they can t be seen from outside the class. May add getter methods (functions) and setter methods (procedures) to allow access to some or all fields. Use a new kind of method, the constructor, to initialize fields of a new object during evaluation of a new-expression. 44
45 Example public class Circle { public double x, y; // centre coordinate public double r; // radius of the circle } The fields (data) are also called the instance variables. 45
46 public class Circle { public double x, y; // centre of the circle public double r; // radius of circle } //Methods to return circumference and area public double circumference() { return 2*3.14*r; } public double area() { return 3.14 * r * r; } Method Body 46
47 Data Abstraction Declare the Circle class, have created a new data type Data Abstraction Can define variables (objects) of that type: Circle acircle; Circle bcircle; acircle, bcirclesimply refers to a Circle object, not an object itself. acircle bcircle Points to nothing (Null Reference) null null 47
48 Creating objects of a class Objects are created dynamically using the new keyword. acircle = new Circle() ; bcircle = new Circle() ; 48
49 49 Non-static classes
50 Non-static classes A utility class has features (fields and methods) that are all static. therefore, you do not need objects to use those features a well implemented utility class should have a single, empty private constructor to prevent the creation of objects Most Java classes are not utility classes they are intended to be used to create to objects each object has its own copy of all non-static fields it is also useful to imagine that each object has its own copy of all non-static methods 50
51 Why objects? Each object has its own copy of all non-static fields this allows objects to have their own state in Java the state of an object is the set of current values of all of its non-static fields Object-oriented programming in Java: Use classes to define templates Use objects to instantiate classes At runtime, create objects and call methods on objects, to simulate interactions between real-life entities. 51
52 Implementing classes Many classes represent kinds of values examples of values: name, date, colour, mathematical point or vector Java examples: String, Date, Integer When implementing a class you need to choose appropriate fields to represent the state of each object Consider implementing a class that represents 2- dimensional points a possible implementation would have: a field to represent the x-coordinate of the point a field to represent the y-coordinate of the point 52
53 /** * A simple class for representing points in 2D Cartesian * coordinates. Every <code>simplepoint2d</code> instance has a * public x and y coordinate that can be directly accessed * and modified. * EECS2030 Winter * */ public class SimplePoint2 { } public float x; public float y; public class: any client can use this class public fields: any client can use these fields by name Note: Client is any class with its main method using the utility methods, Supplier: A single utility class. 53
54 Using SimplePoint2 Even in its current form, we can use SimplePoint2to create and manipulate point objects 54
55 public static void main(string[] args) { // create a point SimplePoint2 p = new SimplePoint2(); // set its coordinates p.x = -1.0f; p.y = 1.5f; } // get its coordinates System.out.println("p = (" + p.x + ", " + p.y + ")"); 55
56 Using SimplePoint2 Notice that printing a point is somewhat inconvenient we have to manually compute a string representation of the point Initializing the coordinates of the point is somewhat inconvenient we have to manually set the x and y coordinates we get unusual results when using equals 56
57 public static void main(string[] args) { // create a point SimplePoint2 p = new SimplePoint2(); // set its coordinates p.x = -1.0f; p.y = 1.5f; // get its coordinates System.out.println("p = (" + p.x + ", " + p.y + ")"); SimplePoint2 q = new SimplePoint2(); q.x = p.x; q.y = p.y; } // equals? System.out.println("p.equals(q) is: " + p.equals(q)); 57
58 Encapsulation We can add features to SimplePoint2to make it easier to use we can add methods that use the fieldsof SimplePoint2to perform some sort of computation (like compute a string representation of the point) we can add constructors that set the values of the fieldsof a SimplePoint2 object when it is created In object oriented programming the term encapsulationmeans bundling data and methods that use the data into a single unit 58 That involves enclosing an object with a kind of protective bubble so that it cannot be accessed or modified without proper permission.
59 Constructors The purpose of a constructor is to initialize the state of an object it should set the values of all of the non-static fields to appropriate values Aconstructor: must have the same name as the class never returns a value (not even void) constructors are not methods can have zero or more parameters 59
60 Default constructor The default constructor has zero parameters The default constructor initializes the state of an object to some well defined state chosen by the implementer 60
61 public class SimplePoint2 { public float x; public float y; /** * The default constructor. Sets both the x and y coordinate * of the point to 0.0f. */ public SimplePoint2() { } this.x = 0.0f; this.y = 0.0f; Inside a constructor, the keyword this is a reference to the object that is currently being initialized. 61
62 Custom constructors A class can have multiple constructors but the signatures of the constructors must be unique i.e., each constructor must have a unique list of parameter types It would be convenient for clients if SimplePoint2 had a constructor that let the client set the x and y coordinate of the point 62
63 public class SimplePoint2 { public float x; public float y; /** * Sets the x and y coordinate of the point to the argument * values. * x the x coordinate of the point y the y coordinate of the point */ public SimplePoint2(float x, float y) { } this.x = x; this.y = y; this.x : the field named xof thispoint this.y : the field named yof this point x : the parameter named xof the constructor y : the parameter named yof the constructor 63
64 SimplePoint2 p = new SimplePoint2(-1.0f, 1.5f); 1. newallocates memory for a SimplePoint2 object p 64 client 600a 2. the SimplePoint2 constructor is invoked by passing the memory address of the object and the arguments -1.0fand 1.5f to the constructor 3. the constructor runs, setting the values of the fields this.xand this.y fields x y 600 SimplePoint2 object -1.0f 1.5f 4. the value of p is set to the memory address of the constructed object parameters this x 700 SimplePoint2 constructor 600a -1.0f y 1.5f 64
65 this In our constructor public SimplePoint2(float x, float y) { this.x = x; this.y = y; } there are parameters with the same names as fields when this occurs, the parameter has precedence over the field we say that the parameter shadowsthe field when shadowing occurs you must use thisto refer to the field 65
66 Custom constructors Adding the constructor SimplePoint2(float x, float y) allows the client to simplify their code 66
67 public static void main(string[] args) { // create a point SimplePoint2 p = new SimplePoint2(); // set its coordinates p.x = -1.0f; p.y = 1.5f; // get its coordinates System.out.println("p = (" + p.x + ", " + p.y + ")"); SimplePoint2 q = new SimplePoint2(); q.x = p.x; q.y = p.y; } // equals? System.out.println("p.equals(q) is: " + p.equals(q)); 67
68 public static void main(string[] args) { // create a point SimplePoint2 p = new SimplePoint2(-1.0f, 1.5f); // set its coordinates p.x = -1.0f; p.y = 1.5f; // get its coordinates System.out.println("p = (" + p.x + ", " + p.y + ")"); SimplePoint2 q = new SimplePoint2(p.x, p.y); q.x = p.x; q.y = p.y; } // equals? System.out.println("p.equals(q) is: " + p.equals(q)); 68
69 Copy constructor A copy constructor initializes the state of an object by copying the state of another object (having the same type) it has a single parameter that is the same type as the class 69
70 public class SimplePoint2 { public float x; public float y; /** * Sets the x and y coordinate of this point by copying * the x and y coordinate of another point. * other a point to copy */ public SimplePoint2(SimplePoint2 other) { this.x = other.x; this.y = other.y; } 70
71 Copy constructor Adding a copy constructor allows the client to simplify their code 71
72 public static void main(string[] args) { // create a point SimplePoint2 p = new SimplePoint2(-1.0f, 1.5f); // set its coordinates p.x = -1.0f; p.y = 1.5f; // get its coordinates System.out.println("p = (" + p.x + ", " + p.y + ")"); SimplePoint2 q = new SimplePoint2(p.x, p.y); q.x = p.x; q.y = p.y; } // equals? System.out.println("p.equals(q) is: " + p.equals(q)); 72
73 public static void main(string[] args) { // create a point SimplePoint2 p = new SimplePoint2(-1.0f, 1.5f); // set its coordinates p.x = -1.0f; p.y = 1.5f; // get its coordinates System.out.println("p = (" + p.x + ", " + p.y + ")"); SimplePoint2 q = new SimplePoint2(p); q.x = p.x; q.y = p.y; } // equals? System.out.println("p.equals(q) is: " + p.equals(q)); 73
74 Avoiding Code Duplication Notice that the constructor bodies are almost identical to each other all three constructors have 2 lines of code all three constructors set the x and y coordinate of the point Whenever you see duplicated code you should consider moving the duplicated code into a method In this case, one of the constructors already does everything we need to implement the other constructors 74
75 Constructor chaining A constructor is allowed to invoke another constructor When a constructor invokes another constructor it is called constructor chaining To invoke a constructor in the same class you use the this keyword if you do this then it must occuron the first line of the constructor body but you cannotuse this in a method to invoke a constructor We can re-write two of our constructors to use constructor chaining... 75
76 public class SimplePoint2 { public float x; public float y; public SimplePoint2() { } this(0.0f, 0.0f); invokes public SimplePoint2(float x, float y) { this.x = x; this.y = y; } public SimplePoint2(SimplePoint2 other) { } this(other.x, other.y); invokes 76
77 References for EECS 2030] 77
Advanced Object Oriented Programming EECS2030Z
Advanced Object Oriented Programming EECS2030Z 1 Academic Support Programs: Bethune having trouble with your FSC and LSE courses? consider using the Academic Support Programs at Bethune College PASS free,
More informationAdvanced Object Oriented Programming EECS2030Z
Advanced Object Oriented Programming EECS2030Z 1 Who Am I? Dr. Burton Ma office Lassonde 2046 hours : to be updated on the syllabus page email burton@cse.yorku.ca 2 Course Format everything you need to
More informationCOMP 250 Winter 2011 Reading: Java background January 5, 2011
Almost all of you have taken COMP 202 or equivalent, so I am assuming that you are familiar with the basic techniques and definitions of Java covered in that course. Those of you who have not taken a COMP
More information1 Shyam sir JAVA Notes
1 Shyam sir JAVA Notes 1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write
More informationGraphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub
Lebanese University Faculty of Science Computer Science BS Degree Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub 2 Crash Course in JAVA Classes A Java
More informationJava Object Oriented Design. CSC207 Fall 2014
Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code
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 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 informationAdvanced Object Oriented Programming EECS2030E
Advanced Object Oriented Programming EECS2030E 1 Academic Support Programs: Bethune having trouble with your FSC and LSE courses? consider using the Academic Support Programs at Bethune College PASS free,
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 informationClasses. Classes. Classes. Class Circle with methods. Class Circle with fields. Classes and Objects in Java. Introduce to classes and objects in Java.
Classes Introduce to classes and objects in Java. Classes and Objects in Java Understand how some of the OO concepts learnt so far are supported in Java. Understand important features in Java classes.
More informationPackages. Examples of package names: points java.lang com.sun.security drawing.figures
Packages To make classes easier to find and to use, to avoid naming conflicts, and to control access, programmers bundle groups of related classes and interfaces into packages. A package is a program module
More informationInstance Members and Static Members
Instance Members and Static Members You may notice that all the members are declared w/o static. These members belong to some specific object. They are called instance members. This implies that these
More informationPace University. Fundamental Concepts of CS121 1
Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction
More informationCS260 Intro to Java & Android 03.Java Language Basics
03.Java Language Basics http://www.tutorialspoint.com/java/index.htm CS260 - Intro to Java & Android 1 What is the distinction between fields and variables? Java has the following kinds of variables: Instance
More informationCS 231 Data Structures and Algorithms, Fall 2016
CS 231 Data Structures and Algorithms, Fall 2016 Dr. Bruce A. Maxwell Department of Computer Science Colby College Course Description Focuses on the common structures used to store data and the standard
More informationCSCE3193: Programming Paradigms
CSCE3193: Programming Paradigms Nilanjan Banerjee University of Arkansas Fayetteville, AR nilanb@uark.edu http://www.csce.uark.edu/~nilanb/3193/s10/ Programming Paradigms 1 Java Packages Application programmer
More informationAnnouncements. 1. Forms to return today after class:
Announcements Handouts (3) to pick up 1. Forms to return today after class: Pretest (take during class later) Laptop information form (fill out during class later) Academic honesty form (must sign) 2.
More informationDay 3. COMP 1006/1406A Summer M. Jason Hinek Carleton University
Day 3 COMP 1006/1406A Summer 2016 M. Jason Hinek Carleton University today s agenda assignments 1 was due before class 2 is posted (be sure to read early!) a quick look back testing test cases for arrays
More informationCO Java SE 8: Fundamentals
CO-83527 Java SE 8: Fundamentals Summary Duration 5 Days Audience Application Developer, Developer, Project Manager, Systems Administrator, Technical Administrator, Technical Consultant and Web Administrator
More informationJAVA: A Primer. By: Amrita Rajagopal
JAVA: A Primer By: Amrita Rajagopal 1 Some facts about JAVA JAVA is an Object Oriented Programming language (OOP) Everything in Java is an object application-- a Java program that executes independently
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 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 informationAl al-bayt University Prince Hussein Bin Abdullah College for Information Technology Computer Science Department
Al al-bayt University Prince Hussein Bin Abdullah College for Information Technology Computer Science Department 0901212 Python Programming 1 st Semester 2014/2015 Course Catalog This course introduces
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 informationF1 A Java program. Ch 1 in PPIJ. Introduction to the course. The computer and its workings The algorithm concept
F1 A Java program Ch 1 in PPIJ Introduction to the course The computer and its workings The algorithm concept The structure of a Java program Classes and methods Variables Program statements Comments Naming
More informationSubclass Gist Example: Chess Super Keyword Shadowing Overriding Why? L10 - Polymorphism and Abstract Classes The Four Principles of Object Oriented
Table of Contents L01 - Introduction L02 - Strings Some Examples Reserved Characters Operations Immutability Equality Wrappers and Primitives Boxing/Unboxing Boxing Unboxing Formatting L03 - Input and
More informationBASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I
BASIC COMPUTATION x public static void main(string [] args) Fundamentals of Computer Science I Outline Using Eclipse Data Types Variables Primitive and Class Data Types Expressions Declaration Assignment
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 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 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 informationComputer Science II (20073) Week 1: Review and Inheritance
Computer Science II 4003-232-01 (20073) Week 1: Review and Inheritance Richard Zanibbi Rochester Institute of Technology Review of CS-I Hardware and Software Hardware Physical devices in a computer system
More informationData Structures (list, dictionary, tuples, sets, strings)
Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in brackets: l = [1, 2, "a"] (access by index, is mutable sequence) Tuples are enclosed in parentheses: t = (1, 2, "a") (access
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 informationFundamentals of Computer Science CSCI 136 Syllabus Fall 2018
Fundamentals of Computer Science CSCI 136 Syllabus Fall 2018 CSCI 136 Section 00 Instructor: Michael Cassens Office: SS 411 Office Hours: MWF 11:00-11:50 am or by appt Phone: (415) 787-0577 E-mail: michael.cassens@mso.umt.edu
More informationChapter 4 Defining Classes I
Chapter 4 Defining Classes I This chapter introduces the idea that students can create their own classes and therefore their own objects. Introduced is the idea of methods and instance variables as the
More informationCOP 3330 Final Exam Review
COP 3330 Final Exam Review I. The Basics (Chapters 2, 5, 6) a. comments b. identifiers, reserved words c. white space d. compilers vs. interpreters e. syntax, semantics f. errors i. syntax ii. run-time
More informationTiming for Interfaces and Abstract Classes
Timing for Interfaces and Abstract Classes Consider using abstract classes if you want to: share code among several closely related classes declare non-static or non-final fields Consider using interfaces
More informationProgramming overview
Programming overview Basic Java A Java program consists of: One or more classes A class contains one or more methods A method contains program statements Each class in a separate file MyClass defined in
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 informationObjects and Classes. 1 Creating Classes and Objects. CSCI-UA 101 Objects and Classes
Based on Introduction to Java Programming, Y. Daniel Liang, Brief Version, 10/E 1 Creating Classes and Objects Classes give us a way of defining custom data types and associating data with operations on
More informationThe Essence of OOP using Java, Nested Top-Level Classes. Preface
The Essence of OOP using Java, Nested Top-Level Classes Baldwin explains nested top-level classes, and illustrates a very useful polymorphic structure where nested classes extend the enclosing class and
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 informationInf1-OP. Inf1-OP Exam Review. Timothy Hospedales, adapting earlier version by Perdita Stevens and Ewan Klein. March 20, School of Informatics
Inf1-OP Inf1-OP Exam Review Timothy Hospedales, adapting earlier version by Perdita Stevens and Ewan Klein School of Informatics March 20, 2017 Overview Overview of examinable material: Lectures Week 1
More informationThe return Statement
The return Statement The return statement is the end point of the method. A callee is a method invoked by a caller. The callee returns to the caller if the callee completes all the statements (w/o a return
More informationPackage. A package is a set of related classes Syntax to put a class into a package: Two rules: Example:
Packages Package A package is a set of related classes Syntax to put a class into a package: package ; public class { } Two rules: q q A package declaration must always come
More informationWrapper Classes double pi = new Double(3.14); 3 double pi = new Double("3.14"); 4... Zheng-Liang Lu Java Programming 290 / 321
Wrapper Classes To treat values as objects, Java supplies standard wrapper classes for each primitive type. For example, you can construct a wrapper object from a primitive value or from a string representation
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 information3D Graphics Programming Mira Costa High School - Class Syllabus,
3D Graphics Programming Mira Costa High School - Class Syllabus, 2009-2010 INSTRUCTOR: Mr. M. Williams COURSE GOALS and OBJECTIVES: 1 Learn the fundamentals of the Java language including data types and
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 informationAnother IS-A Relationship
Another IS-A Relationship Not all classes share a vertical relationship. Instead, some are supposed to perform the specific methods without a vertical relationship. Consider the class Bird inherited from
More informationInheritance and Interfaces
Inheritance and Interfaces Object Orientated Programming in Java Benjamin Kenwright Outline Review What is Inheritance? Why we need Inheritance? Syntax, Formatting,.. What is an Interface? Today s Practical
More informationCMSC 341. Nilanjan Banerjee
CMSC 341 Nilanjan Banerjee http://www.csee.umbc.edu/~nilanb/teaching/341/ Announcements Just when you thought Shawn was going to teach this course! On a serious note: register on Piazza I like my classes
More informationExample: Fibonacci Numbers
Example: Fibonacci Numbers Write a program which determines F n, the (n + 1)-th Fibonacci number. The first 10 Fibonacci numbers are 0, 1, 1, 2, 3, 5, 8, 13, 21, and 34. The sequence of Fibonacci numbers
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 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 informationCourse Description. Learn To: : Intro to JAVA SE7 and Programming using JAVA SE7. Course Outline ::
Module Title Duration : Intro to JAVA SE7 and Programming using JAVA SE7 : 9 days Course Description The Java SE 7 Fundamentals course was designed to enable students with little or no programming experience
More informationExample packages from Java s standard class library:
CBOP3203 A class library is a set of classes that supports the development of programs. Java contains an extensive library of prewritten classes you can use in your programs. These classes are divided
More informationAbout this exam review
Final Exam Review About this exam review I ve prepared an outline of the material covered in class May not be totally complete! Exam may ask about things that were covered in class but not in this review
More informationContents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix
PGJC4_JSE8_OCA.book Page ix Monday, June 20, 2016 2:31 PM Contents Figures Tables Examples Foreword Preface xix xxi xxiii xxvii xxix 1 Basics of Java Programming 1 1.1 Introduction 2 1.2 Classes 2 Declaring
More informationG Programming Languages Spring 2010 Lecture 9. Robert Grimm, New York University
G22.2110-001 Programming Languages Spring 2010 Lecture 9 Robert Grimm, New York University 1 Review Last week Modules 2 Outline Classes Encapsulation and Inheritance Initialization and Finalization Dynamic
More informationFor this section, we will implement a class with only non-static features, that represents a rectangle
For this section, we will implement a class with only non-static features, that represents a rectangle 2 As in the last lecture, the class declaration starts by specifying the class name public class Rectangle
More informationLab5. Wooseok Kim
Lab5 Wooseok Kim wkim3@albany.edu www.cs.albany.edu/~wooseok/201 Question Answer Points 1 A 8 2 A 8 3 E 8 4 D 8 5 20 5 for class 10 for main 5 points for output 6 A 8 7 B 8 8 0 15 9 D 8 10 B 8 Question
More informationDeclarations and Access Control SCJP tips
Declarations and Access Control www.techfaq360.com SCJP tips Write code that declares, constructs, and initializes arrays of any base type using any of the permitted forms both for declaration and for
More informationUnit3: Java in the large. Prepared by: Dr. Abdallah Mohamed, AOU-KW
Prepared by: Dr. Abdallah Mohamed, AOU-KW 1 1. Introduction 2. Objects and classes 3. Information hiding 4. Constructors 5. Some examples of Java classes 6. Inheritance revisited 7. The class hierarchy
More informationJava: introduction to object-oriented features
Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Java: introduction to object-oriented features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer
More informationCS503 Advanced Programming I CS305 Computer Algorithms I
Syllabus: CS503 Advanced Programming I CS305 Computer Algorithms I Course Number: CS503-50/CS305-50 Course Title: Advanced Programming I/Computer Algorithms I Instructor: Richard Scherl Office: Howard
More informationEECS 1001 and EECS 1030M, lab 01 conflict
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,
More informationCSCE 156 Computer Science II
CSCE 156 Computer Science II Lab 04 - Classes & Constructors Dr. Chris Bourke Prior to Lab 1. Review this laboratory handout prior to lab. 2. Read Object Creation tutorial: http://download.oracle.com/javase/tutorial/java/javaoo/objectcreation.
More informationJava for Programmers Course (equivalent to SL 275) 36 Contact Hours
Java for Programmers Course (equivalent to SL 275) 36 Contact Hours Course Overview This course teaches programmers the skills necessary to create Java programming system applications and satisfies the
More informationAgenda. Objects and classes Encapsulation and information hiding Documentation Packages
Preliminaries II 1 Agenda Objects and classes Encapsulation and information hiding Documentation Packages Inheritance Polymorphism Implementation of inheritance in Java Abstract classes Interfaces Generics
More informationChapter 2: Java OOP I
Chapter 2: Java OOP I Yang Wang wyang AT njnet.edu.cn Outline OO Concepts Class and Objects Package Field Method Construct and Initialization Access Control OO Concepts Object Oriented Methods Object An
More informationProject #1 rev 2 Computer Science 2334 Fall 2013 This project is individual work. Each student must complete this assignment independently.
Project #1 rev 2 Computer Science 2334 Fall 2013 This project is individual work. Each student must complete this assignment independently. User Request: Create a simple magazine data system. Milestones:
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 informationOverview of OOP. Dr. Zhang COSC 1436 Summer, /18/2017
Overview of OOP Dr. Zhang COSC 1436 Summer, 2017 7/18/2017 Review Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in square brackets: l = [1, 2, "a"] (access by index, is mutable
More informationCS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims
CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims Lecture 1: Overview http://courses.cs.cornell.edu/cs2110 1 Course Staff Instructor Thorsten Joachims (tj@cs.cornell.edu)
More informationCS506 Web Design & Development Final Term Solved MCQs with Reference
with Reference I am student in MCS (Virtual University of Pakistan). All the MCQs are solved by me. I followed the Moaaz pattern in Writing and Layout this document. Because many students are familiar
More informationLab5. Wooseok Kim
Lab5 Wooseok Kim wkim3@albany.edu www.cs.albany.edu/~wooseok/201 Question Answer Points 1 A or B 8 2 A 8 3 D 8 4 20 5 for class 10 for main 5 points for output 5 D or E 8 6 B 8 7 1 15 8 D 8 9 C 8 10 B
More informationJava Fundamentals (II)
Chair of Software Engineering Languages in Depth Series: Java Programming Prof. Dr. Bertrand Meyer Java Fundamentals (II) Marco Piccioni static imports Introduced in 5.0 Imported static members of a class
More informationPIC 20A The Basics of Java
PIC 20A The Basics of Java Ernest Ryu UCLA Mathematics Last edited: November 1, 2017 Outline Variables Control structures classes Compilation final and static modifiers Arrays Examples: String, Math, and
More informationJava Intro 3. Java Intro 3. Class Libraries and the Java API. Outline
Java Intro 3 9/7/2007 1 Java Intro 3 Outline Java API Packages Access Rules, Class Visibility Strings as Objects Wrapper classes Static Attributes & Methods Hello World details 9/7/2007 2 Class Libraries
More informationJava SE 8 Programming
Oracle University Contact Us: +52 1 55 8525 3225 Java SE 8 Programming Duration: 5 Days What you will learn This Java SE 8 Programming training covers the core language features and Application Programming
More informationKOMAR UNIVERSITY OF SCIENCE AND TECHNOLOGY (KUST)
Programming Concepts & Algorithms Course Syllabus Course Title Course Code Computer Department Pre-requisites Course Code Course Instructor Programming Concepts & Algorithms + lab CPE 405C Computer Department
More informationCONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17
List of Programs xxv List of Figures xxix List of Tables xxxiii Preface to second version xxxv PART 1 Structured Programming 1 1 Getting started 3 1.1 Programming 3 1.2 Editing source code 5 Source code
More informationInf1-OOP. OOP Exam Review. Perdita Stevens, adapting earlier version by Ewan Klein. March 16, School of Informatics
Inf1-OOP OOP Exam Review Perdita Stevens, adapting earlier version by Ewan Klein School of Informatics March 16, 2015 Overview Overview of examinable material: Lectures Topics S&W sections Week 1 Compilation,
More informationAP Computer Science A
AP Computer Science A Couse Information: Couse Title: AP Computer Science A Couse Number: 8317 Length of Course: Full year No. of Credits: 1.0 Instructor Information: Instructor: Michael George Email:
More informationInterfaces. An interface forms a contract between the object and the outside world.
Interfaces An interface forms a contract between the object and the outside world. For example, the buttons on the television set are the interface between you and the electrical wiring on the other side
More informationWeiss Chapter 1 terminology (parenthesized numbers are page numbers)
Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement
More informationhttps://asd-pa.perfplusk12.com/admin/admin_curric_maps_display.asp...
1 of 8 8/27/2014 2:15 PM Units: Teacher: ProgIIIAPCompSci, CORE Course: ProgIIIAPCompSci Year: 2012-13 Computer Systems This unit provides an introduction to the field of computer science, and covers the
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 informationIntroduction Basic elements of Java
Software and Programming I Introduction Basic elements of Java Roman Kontchakov / Carsten Fuhs Birkbeck, University of London Module Information Time: Thursdays in the Spring term Lectures: MAL B04: 2
More informationAdministration. Classes. Objects Part II. Agenda. Review: Object References. Object Aliases. CS 99 Summer 2000 Michael Clarkson Lecture 7
Administration Classes CS 99 Summer 2000 Michael Clarkson Lecture 7 Lab 7 due tomorrow Question: Lab 6.equals( SquareRoot )? Lab 8 posted today Prelim 2 in six days! Covers two weeks of material: lectures
More informationCS 215 Software Design Homework 3 Due: February 28, 11:30 PM
CS 215 Software Design Homework 3 Due: February 28, 11:30 PM Objectives Specifying and checking class invariants Writing an abstract class Writing an immutable class Background Polynomials are a common
More informationJava SE 8 Programming
Oracle University Contact Us: Local: 1800 103 4775 Intl: +91 80 67863102 Java SE 8 Programming Duration: 5 Days What you will learn This Java SE 8 Programming training covers the core language features
More informationJava: advanced object-oriented features
Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Java: advanced object-oriented features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Packages
More informationIntroduction to Programming System Design CSCI 455x (4 Units)
Introduction to Programming System Design CSCI 455x (4 Units) Description This course covers programming in Java and C++. Topics include review of basic programming concepts such as control structures,
More informationQuestions Answer Key Questions Answer Key Questions Answer Key
Benha University Term: 2 nd (2013/2014) Class: 2 nd Year Students Subject: Object Oriented Programming Faculty of Computers & Informatics Date: 26/4/2014 Time: 1 hours Exam: Mid-Term (A) Name:. Status:
More informationB2.52-R3: INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING THROUGH JAVA
B2.52-R3: INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING THROUGH JAVA NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE
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 informationThis course supports the assessment for Scripting and Programming Applications. The course covers 4 competencies and represents 4 competency units.
This course supports the assessment for Scripting and Programming Applications. The course covers 4 competencies and represents 4 competency units. Introduction Overview Advancements in technology are
More information