Inf1-OOP. Data Types. A Foundation for Programming. type value set operations. Overview. Using Data Types 1. Image Processing

Size: px
Start display at page:

Download "Inf1-OOP. Data Types. A Foundation for Programming. type value set operations. Overview. Using Data Types 1. Image Processing"

Transcription

1 Inf1-OOP Using Data Types 1 Ewan Klein, Perdita Stevens School of Informatics January 10, 2013 Overview Image Processing String Processing Summary/Admin 1 Thanks to Sedgewick&Wayne for much of this content A Foundation for Programming Data Types Data type: a set of values and operations on those values. Primitive types: data types whose operations translate directly to machine instructions. objects functions and modules graphics, sound and image I/O arrays conditionals and loops create your own data types type value set operations int integers add, subtract, multiply, divide double floating-point numbers add, subtract, multiply, divide boolean truth values and, or, not Math primitive data types text I/O assignment statements But we want to write code that will process other types of data: Colors, pictures, strings, input streams,... Complex numbers, vectors, matrices, polynomials,... Points, polygons, charged particles, celestial bodies,...

2 User-defined data types Object An object has state, behaviour and identity. Java is a class-based object-oriented language. A class is a kind of data type that you can define yourself. An object is an instance of a class. The code in a Java system is organised into classes. The system runs by objects sending messages to one another, and reacting to receiving messages, possibly by sending other messages... the sender trusts the receiver to do the right thing (Most) variables refer to objects. State: the data that the object encapsulates the object may decide to modify its state in response to a message but immutable objects never do this Behaviour: the messages the object understands, and what it does in response exactly what an object does in response to a message may depend on its state Identity: two objects may currently have identical data, but be different objects e.g. o1 and o2 could be in the same state now, but not after you sent a message to o1, which affects o1 s state but not o2 s. Why use object orientation? OO has taken the world by storm. Why? For programming, OOP is nice, but not clearly better than FP, say. For software engineering, OO is definitely better use objects to model real-world things use classes to model domain concepts. These change more slowly than specific functional requirements, so what OO does is to put things together that change together as requirements evolve. Change is the thing that makes software engineering hard and interesting; OO helps manage it. for most applications, E&OE, don t tell PW I said so :-)

3 Constructors and Methods Static Methods vs. Instance Methods declare a variable (object name) String s; call a constructor to create an object s = new String("Hello, World!"); System.out.println( s.substring(0, 5) ); object name call an instance method that operates on the object's value Static Methods: Associated with a class. Identifying a method in a separate class requires name of the class: Math.abs(), PointDistance.distance(). Instance Methods: Associated with an object. Identifying an instance method requires an object name: s.substring() Colour Data Type Colour: a visual perception property in humans deriving from interaction of the eye with electromagnetic radiation. Set of values (RGB representation): possible values, which quantify the amount of red, green and blue, each on a scale of 0 to 255. R G B Colour Java Color API public class java.awt.color Color(int r, int g, int b) constructor int getred() red intensity int getgreen() green intensity int getblue() blue intensity Color brighter() brighter version of this colour Color darker() darker version of this colour String tostring() string representation of this colour boolean equals(color c) is this colour s value the same as c s? Color.html Standard format for expressing APIs. Will be used in coming weeks.

4 Albers Squares Albers Squares blue grey % java AlbersSquares Homage to the Square, Josef Albers (series painted ) Using Colours in Java Using Colours in Java import java.awt.color; access the Color library public class AlbersSquares { public static void main(string[] args) { int r1 = Integer.parseInt(args[0]); int g1 = Integer.parseInt(args[1]); int b1 = Integer.parseInt(args[2]); Color c1 = new Color(r1, g1, b1); int r2 = Integer.parseInt(args[3]); int g2 = Integer.parseInt(args[4]); int b2 = Integer.parseInt(args[5]); Color c2 = new Color(r2, g2, b2); StdDraw.setPenColor(c1); StdDraw.filledSquare(.25,.5,.2); StdDraw.setPenColor(c2); StdDraw.filledSquare(.25,.5,.1); first colour second colour first square Color c1 = new Color(r1, g1, b1): Call the Color constructor to create a new color object c1 with arguments for RGB. Example makes use of StdDraw library filledsquare(double x, double y, double r): Draw a filled square of side length 2r, centered on (x, y). StdDraw.setPenColor(c2); StdDraw.filledSquare(.75,.5,.2); StdDraw.setPenColor(c1); StdDraw.filledSquare(.75,.5,.1); second square

5 Monochrome Luminance Colour Compatibility Monochrome Luminance: effective brightness of a colour. In TV transmission, calculated as the weighted sum of R, G and B. NTSC formula for luminance: Y = (0.299 R) + (0.587 G) + (0.114 B) import java.awt.color; public class Luminance { public static double luminance(color color) { int r = color.getred(); int g = color.getgreen(); int b = color.getblue(); return 0.299*r *g *b; Q: Which font colours will be most readable on given background colours on computer and mobile phone screens? A: Rule of thumb: luminance should be Grayscale Grayscale: when all three R, G and B values are the same, the resulting colour is on grayscale, from 0 (black) to 255 (white). Conversion: Coloured images can be converted to grayscale using luminance to determine the value. public static Color togrey(color color) { int y = (int) (Math.round(lum(color))); Color gray = new Color(y, y, y); return grey; round double to nearest int red green blue this colour: grayscale version: black: Color Data Type The Color data type is a way of abstracting away from the physical reality of colour. Separates the task of specifying and manipulating colours from the task of reproducing colours in various mediums (print, web, photos,... ). The Color data type implements one particular model of colour, namely RGB (three 8-bit integers). Y = ( ) + ( ) + ( ) =

6 Color Data Type OOP Context for Colour Possible memory representation: D0 D1 D2 D3 D4 D5 D6 D7 D8 The method luminance() takes a parameter of type Color, which in turn allows it to call methods that are part of the Color API; e.g., Color.getRed(). The method togrey() returns a value of type Color, which in effect allows it to return a bundle of three integer values (i.e., the RGB values of a particular colour). Color is called reference type (vs. primitive type) magenta A0 D0 memory address ("pointer") B0 D6 gray Object reference is analogous to variable name: We can manipulate the value that it holds. We can pass it to a method, or return it from one. String Data Type String Data Type: basis for text processing Set of Values: sequence of Unicode characters public class String String(String s) create a string with same value as s int length() return length of string char charat(int i) i th character String substring(int i, int j) i th through (j 1) th characters boolean contains(string sub) does string contain sub as a substring? boolean startswith(string pre) does string start with pre? boolean startswith(string post) does string end with post? int indexof(string p) index of first occurrence of p int indexof(string p, int i) index of first occurrence of p after i String concat(string t) this string with t appended int compareto(string t) compare lexicographically with t String replaceall(string a, String b) result of changing all as to bs String[] split(string delim) result of splitting string at delim boolean equals(string t) is this string the same as t? http: //download.oracle.com/javase/6/docs/api/java/lang/string.html Typical String Processing Code is the string a palindrome? extract filenames and extensions from a command-line argument print all lines from standard input containing the string info print all ac.uk URLs in text file on standard input public static boolean ispalindrome(string s) { int N = s.length(); for (int i = 0; i < N / 2; i++) { if (s.charat(i)!= s.charat(n i)) return false; return true; String s = args[0]; int dot = s.indexof("."); String base = s.substring(0, dot); String extension = s.substring(dot + 1, s.length()); while (!StdIn.isEmpty()) { String s = StdIn.readLine(); if (s.contains("info")) System.out.println(s); while (!StdIn.isEmpty()) { String s = StdIn.readString(); if (s.startswith(" && s.endswith("ac.uk" System.out.println(s);

7 Gene Finding Gene Finding: Algorithm Pregenomic era: Sequencing the human genome [Human Genome Project, 2003]. Postgenomic era: Analyse the data and understand structure. Genome: Represent genome as a string over {A, C, T, G alphabet. Gene: A substring of genome that represents a functional unit. Preceded by ATG (start codon). Multiples of three nucleotides (codons other than start/stop). Succeeded by TAG, TAA or TGA (stop codons). Goal: find all genes A T A G A T G C A T A G C G C A T A G C T A G A T G T G C T A G C start gene stop gene Algorithm: Scan left-to-right through genome. If start codon, then set beg to index i. If stop codon and substring is multiple of 3: output gene reset beg to -1 i start stop beg gene remaining portion of input 0-1 ATAGATGCATAGCGCATAGCTAGATGTGCTA 1 TAG -1 ATAGATGCATAGCGCATAGCTAGATGTGCTA 4 ATG 4 ATAGATGCATAGCGCATAGCTAGATGTGCTA 9 TAG 4 ATAGATGCATAGCGCATAGCTAGATGTGCTA 16 TAG 4 CATAGCGCA ATAGATGCATAGCGCATAGCTAGATGTGCTA 20 TAG -1 ATAGATGCATAGCGCATAGCTAGATGTGCTA 23 ATG 23 ATAGATGCATAGCGCATAGCTAGATGTGCTA 29 TAG 23 TGC ATAGATGCATAGCGCATAGCTAGATGTGCTA Strings and Equality OOP Framework for Strings Possible memory representation of a string genome = "AACAAGTTTACAAGC" equals(): are the characters inside a String object the same? ==: do the two object references refer to the same instance? In all the coursework for this course, you should be using equals() for checking whether two strings are the same D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE A0 A1 A A C A A G T T T A C A A G C D0 15 s = genome.substring(1, 5); t = genome.substring(9, 13); s memory address genome t B0 B1 B2 B3 D1 4 D9 4 length (s == t) is false (s.equals(t)) is true s and t are different strings that share the same value "ACAA"

8 Two-Dimensional Arrays Two-Dimensional Arrays in Java Array access: Use a[i][j] to access element in row i and column j. Zero-based indexing: Row and column indices start at 0. Examples of two-dimensional arrays: Table of data for each experiment and outcome. Table of grades for each student and assignment. Table of grayscale values for each pixel in a 2D image. Mathematical abstraction: matrix Java abstraction: 2D Array int M = 10; int N = 3; double[][] a = new double[m][n]; for (int i = 0; i < M; i++) { for (int j = 0; j < N; j++) { a[i][j] = 0.0; Initialize a 10-by-3 array of doubles a[ ][ ] a[5] a[0][0] a[0][1] a[0][2] a[1][0] a[1][1] a[1][2] a[2][0] a[2][1] a[2][2] a[3][0] a[3][1] a[3][2] a[4][0] a[4][1] a[4][2] a[5][0] a[5][1] a[5][2] a[6][0] a[6][1] a[6][2] a[7][0] a[7][1] a[7][2] a[8][0] a[8][1] a[8][2] a[9][0] a[9][1] a[9][2] A 10-by-3 array Setting 2D Array Values at Compile Time Initialize 2D array of doubles by listing values. Each element of the array p is itself an array of type double[]. Two-Dimensional Arrays in Java double[][] p = { {.02,.92,.02,.02,.02, {.02,.02,.32,.32,.32, {.02,.02,.02,.92,.02, {.92,.02,.02,.02,.02, {.47,.02,.47,.02,.02, ; MN Name Age MBox Gend s Peter 18 peter@math M s Michael 21 mike@geo M s Helen 20 helen@phys F s Mary 18 mary@inf F s John 21 john@inf M

9 Two Dimensional Arrays, 1 Two Dimensional Arrays, 2 Array of Arrays String[][] students = new String[5][]; students is an array of length 5 Each element of students is itself an array, of type String[]. Directly assign values to 5 new String[] arrays: Initialize some Elements String[] michael = { "s ", "Michael", "21", "mike@geo", "M" ; String[] peter = { "s ", "Peter", "18", "peter@math", "M" ; String[] helen = { "s ", "Helen", "20", "helen@phys", "F" ; String[] mary = { "s ", "Mary", "18", "mary@inf", "F" ; String[] john = { "s ", "John", "21", "john@inf", "M" ; Two Dimensional Arrays, 3 Two Dimensional Arrays, 4 Now make these be the rows in students: Assigning values to the rows students[0] = peter; students[1] = michael; students[2] = helen; students[3] = mary; students[4] = john; students[i][j] selects the i th row and the j th column of the table. Schematically: Indexing into the 2D array [0][0], [0][1], [0][2], [0][3], [0][4] [1][0], [1][1], [1][2], [1][3], [1][4] [2][0], [2][1], [2][2], [2][3], [2][4] [3][0], [3][1], [3][2], [3][3], [3][4] [4][0], [4][1], [4][2], [4][3], [4][4] Michael s Mbox? (students[1][3]) Mary s Name? (students[3][3])

10 Summary Sedgewick & Wayne: Reading An object is an instance of a class, which is a kind of data type often represents a real-world thing has state, behaviour and identity. A variable can have a primitive type e.g., boolean, int, double; or a reference type: any class, e.g. String, Picture, Color, any array type. Data Types Read Section 3.1 (pp )

Inf1-OOP. Data Types. A Foundation for Programming. type value set operations. Overview. Using Data Types 1. Image Processing

Inf1-OOP. Data Types. A Foundation for Programming. type value set operations. Overview. Using Data Types 1. Image Processing Inf1-OOP Using Data Types 1 Perdita Stevens, adapting earlier version by Ewan Klein School of Informatics January 11, 2014 Overview Image Processing String Processing Summary/Admin 1 Thanks to Sedgewick&Wayne

More information

Inf1-OP. Classes and Objects. Timothy Hospedales, adapting earlier version by Perdita Stevens and Ewan Klein. November 23, School of Informatics

Inf1-OP. Classes and Objects. Timothy Hospedales, adapting earlier version by Perdita Stevens and Ewan Klein. November 23, School of Informatics Inf1-OP Classes and Objects Timothy Hospedales, adapting earlier version by Perdita Stevens and Ewan Klein School of Informatics November 23, 2017 Software engineering as managing change The computer doesn

More information

Software engineering as managing change. Inf1-OP. Data representation. How can we make change easier and cheaper?

Software engineering as managing change. Inf1-OP. Data representation. How can we make change easier and cheaper? Software engineering as managing change Inf1-OP Classes and Objects Timothy Hospedales, adapting earlier version by Perdita Stevens and Ewan Klein School of Informatics February 13, 2017 The computer doesn

More information

Using data types. Overview. Data types. Why custom data types? Using data types. A slight diversion: Methods. Data type. Data type

Using data types. Overview. Data types. Why custom data types? Using data types. A slight diversion: Methods. Data type. Data type Using data types Using data types Overview What they are Constructors and methods Application Programming Interface (API) Image processing Text processing A slight diversion: Incrementing and decrementing

More information

9. Abstract Data Types

9. Abstract Data Types COMPUTER SCIENCE COMPUTER SCIENCE Overview Color Image processing String processing Section 3.1 http://introcs.cs.princeton.edu CS.9.A.ADTs.Overview Abstract data types Object-oriented programming (OOP)

More information

9. Abstract Data Types

9. Abstract Data Types COMPUTER SCIENCE S E D G E W I C K / W A Y N E 9. Abstract Data Types Section 3.1 http://introcs.cs.princeton.edu COMPUTER SCIENCE S E D G E W I C K / W A Y N E 9. Abstract Data Types Overview Color Image

More information

9. Abstract Data Types

9. Abstract Data Types COMPUTER SCIENCE S E D G E W I C K / W A Y N E 9. Abstract Data Types Section 3.1 http://introcs.cs.princeton.edu COMPUTER SCIENCE S E D G E W I C K / W A Y N E 9. Abstract Data Types Overview Color Image

More information

3.1 Using Data Types. Data Type. Constructors and Methods. Objects. Data type. Set of values and operations on those values.

3.1 Using Data Types. Data Type. Constructors and Methods. Objects. Data type. Set of values and operations on those values. Data Types 3.1 Using Data Types Data type. Set of values and operations on those values. Primitive types. Ops directly translate to machine instructions. Data Type boolean int double Set of Values true,

More information

3.1 Data Types. Abstract Data Types. Objects. Object. Holds a data type value; variable name refers to object.

3.1 Data Types. Abstract Data Types. Objects. Object. Holds a data type value; variable name refers to object. 3.1 Data Types any program you might want to write objects create your own data types functions and modules graphics, sound, and image I/O arrays conditionals and loops Math primitive data types text I/O

More information

Using data types Fundamentals of Computer Science Keith Vertanen Copyright 2013

Using data types Fundamentals of Computer Science Keith Vertanen Copyright 2013 Using data types Fundamentals of Computer Science Keith Vertanen Copyright 213 Using data types Overview What they are Constructors and methods Applica;on Programming Interface (API) Image processing Text

More information

A Foundation for Programming

A Foundation for Programming 3.1 Using Data Types Introduction to Programming in Java: An Interdisciplinary Approach Robert Sedgewick and Kevin Wayne Copyright 2008 11/20/09 11/20/09 A Foundation for Programming any program you might

More information

Inf1-OOP. Data Types. Defining Data Types in Java. type value set operations. Overview. Circle Class. Creating Data Types 1.

Inf1-OOP. Data Types. Defining Data Types in Java. type value set operations. Overview. Circle Class. Creating Data Types 1. Overview Inf1-OOP Creating Data Types 1 Circle Class Object Default Perdita Stevens, adapting earlier version by Ewan Klein Format Strings School of Informatics January 11, 2015 HotelRoom Class More on

More information

Inf1-OOP. Arrays. Many Variables of the Same Type. Arrays Introduction to Arrays Arrays in Java Shuffling a Deck Multidimensional Arrays Summary/Admin

Inf1-OOP. Arrays. Many Variables of the Same Type. Arrays Introduction to Arrays Arrays in Java Shuffling a Deck Multidimensional Arrays Summary/Admin Inf1-OOP Arrays 1 Perdita Stevens, adapting earlier version by Ewan Klein School of Informatics Arrays Introduction to Arrays Arrays in Java Shuffling a Deck Multidimensional Arrays Summary/Admin January

More information

Inf1-OOP. Arrays 1. Perdita Stevens, adapting earlier version by Ewan Klein. January 11, School of Informatics

Inf1-OOP. Arrays 1. Perdita Stevens, adapting earlier version by Ewan Klein. January 11, School of Informatics Inf1-OOP Arrays 1 Perdita Stevens, adapting earlier version by Ewan Klein School of Informatics January 11, 2015 1 Thanks to Sedgewick&Wayne for much of this content Arrays Introduction to Arrays Arrays

More information

Inf1-OOP. Encapsulation and Collections. Perdita Stevens, adapting earlier version by Ewan Klein. March 2, School of Informatics

Inf1-OOP. Encapsulation and Collections. Perdita Stevens, adapting earlier version by Ewan Klein. March 2, School of Informatics Inf1-OOP Encapsulation and Collections Perdita Stevens, adapting earlier version by Ewan Klein School of Informatics March 2, 2015 Encapsulation Accessing Data Immutability Enhanced for loop Collections

More information

Inf1-OOP. Encapsulation. Object Oriented Programming. Encapsulation Accessing Data Immutability. Encapsulation and Collections.

Inf1-OOP. Encapsulation. Object Oriented Programming. Encapsulation Accessing Data Immutability. Encapsulation and Collections. Inf1-OOP Encapsulation and Collections Ewan Klein, Perdita Stevens School of Informatics January 12, 2013 Encapsulation Accessing Data Immutability Enhanced for loop Collections ArrayList Maps Summary/Admin

More information

Tutorials. Inf1-OP. Learning Outcomes for this week. A Foundation for Programming. Conditionals and Loops 1

Tutorials. Inf1-OP. Learning Outcomes for this week. A Foundation for Programming. Conditionals and Loops 1 Tutorials Inf1-OP Conditionals and Loops 1 Volker Seeker, adapting earlier version by Perdita Stevens and Ewan Klein Start this week please let the ITO know if you need to switch tutorial groups. Labs

More information

Inf1-OP. Collections. Perdita Stevens, adapting earlier version by Ewan Klein. January 9, School of Informatics

Inf1-OP. Collections. Perdita Stevens, adapting earlier version by Ewan Klein. January 9, School of Informatics Inf1-OP Collections Perdita Stevens, adapting earlier version by Ewan Klein School of Informatics January 9, 2016 Rigidity of arrays Length of array is fixed at creation time. Can t be expanded. Can t

More information

Inf1-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. 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 information

Review Chapters 1 to 4. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013

Review Chapters 1 to 4. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 Review Chapters 1 to 4 Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 Introduction to Java Chapters 1 and 2 The Java Language Section 1.1 Data & Expressions Sections 2.1 2.5 Instructor:

More information

Inf1-OP. Arrays 1. Timothy Hospedales, adapting earlier version by Perdita Stevens and Ewan Klein. January 30, School of Informatics

Inf1-OP. Arrays 1. Timothy Hospedales, adapting earlier version by Perdita Stevens and Ewan Klein. January 30, School of Informatics Inf1-OP Arrays 1 Timothy Hospedales, adapting earlier version by Perdita Stevens and Ewan Klein School of Informatics January 30, 2017 1 Thanks to Sedgewick&Wayne for much of this content Arrays Arrays:

More information

Arrays. Inf1-OP. Arrays. Many Variables of the Same Type. Arrays 1. Volker Seeker, adapting earlier version by Perdita Stevens and Ewan Klein

Arrays. Inf1-OP. Arrays. Many Variables of the Same Type. Arrays 1. Volker Seeker, adapting earlier version by Perdita Stevens and Ewan Klein Inf1-OP Arrays 1 Volker Seeker, adapting earlier version by Perdita Stevens and Ewan Klein Arrays School of Informatics February 26, 2018 1 Thanks to Sedgewick&Wayne for much of this content Arrays Arrays:

More information

Inf1-OP. Arrays 1. Volker Seeker, adapting earlier version by Perdita Stevens and Ewan Klein. February 26, School of Informatics

Inf1-OP. Arrays 1. Volker Seeker, adapting earlier version by Perdita Stevens and Ewan Klein. February 26, School of Informatics Inf1-OP Arrays 1 Volker Seeker, adapting earlier version by Perdita Stevens and Ewan Klein School of Informatics February 26, 2018 1 Thanks to Sedgewick&Wayne for much of this content Arrays Arrays Arrays:

More information

Inf1-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. 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 information

Learning Outcomes for this week. Inf1-OP. A Foundation for Programming. A Foundation for Programming

Learning Outcomes for this week. Inf1-OP. A Foundation for Programming. A Foundation for Programming Learning Outcomes for this week Inf1-OP Conditionals and Loops 1 Perdita Stevens, adapting earlier version by Ewan Klein School of Informatics January 9, 2016 Use if and if-else statements to execute a

More information

1.4 Arrays. A Foundation for Programming. Arrays. Many Variables of the Same Type. This lecture. Store and manipulate huge quantities of data.

1.4 Arrays. A Foundation for Programming. Arrays. Many Variables of the Same Type. This lecture. Store and manipulate huge quantities of data. A Foundation for Programming 1.4 Arrays any program you might want to write objects functions and modules graphics, sound, and image I/O arrays store and manipulate huge quantities of data conditionals

More information

Admin. CS 112 Introduction to Programming. Exercise: Gene Finding. Language Organizing Structure. Gene Finding. Foundational Programming Concepts

Admin. CS 112 Introduction to Programming. Exercise: Gene Finding. Language Organizing Structure. Gene Finding. Foundational Programming Concepts Admin CS 112 Introduction to Programming q PS6 (Sukoku) questions? q Planning of remaining of the semester User-Defined Data Types Yang (Richard) Yang Computer Science Department Yale University 308A Watson,

More information

Rigidity of arrays. Inf1-OP. ArrayList. ArrayList: Methods. Declaration. Collections

Rigidity of arrays. Inf1-OP. ArrayList. ArrayList: Methods. Declaration. Collections Rigidity of arrays Inf1-OP Collections Volker Seeker, adapting earlier version by Perdita Stevens and Ewan Klein School of Informatics Length of array is fixed at creation time. Can t be expanded. Can

More information

CS 112 Introduction to Programming

CS 112 Introduction to Programming CS 112 Introduction to Programming (Spring 2012) Lecture #9: Arrays Zhong Shao Department of Computer Science Yale University Office: 314 Watson http://flint.cs.yale.edu/cs112 Acknowledgements: some slides

More information

Inf1-OP. Collections. Timothy Hospedales, adapting earlier version by Perdita Stevens and Ewan Klein. March 6, School of Informatics

Inf1-OP. Collections. Timothy Hospedales, adapting earlier version by Perdita Stevens and Ewan Klein. March 6, School of Informatics Inf1-OP Collections Timothy Hospedales, adapting earlier version by Perdita Stevens and Ewan Klein School of Informatics March 6, 2017 Rigidity of arrays Length of array is fixed at creation time. Can

More information

A foundation for programming. Classes and objects. Overview. Java primitive types. Primitive types Creating your own data types

A foundation for programming. Classes and objects. Overview. Java primitive types. Primitive types Creating your own data types Classes and objects A foundation for programming any program you might want to write objects functions and modules build even bigger programs and reuse code http://www.flickr.com/photos/vermegrigio/5923415248/

More information

A variable is a name for a location in memory A variable must be declared

A variable is a name for a location in memory A variable must be declared Variables A variable is a name for a location in memory A variable must be declared, specifying the variable's name and the type of information that will be held in it data type variable name int total;

More information

CLASSES AND OBJECTS. Fundamentals of Computer Science I

CLASSES AND OBJECTS. Fundamentals of Computer Science I CLASSES AND OBJECTS Fundamentals of Computer Science I Outline Primitive types Creating your own data types Classes Objects Instance variables Instance methods Constructors Arrays of objects A Foundation

More information

More on variables and methods

More on variables and methods More on variables and methods Robots Learning to Program with Java Byron Weber Becker chapter 7 Announcements (Oct 12) Reading for Monday Ch 7.4-7.5 Program#5 out Character Data String is a java class

More information

Inf1-OOP. Textbooks. Who and What. Organisational issues. Why Java? Course Overview. Hello, World! in Java

Inf1-OOP. Textbooks. Who and What. Organisational issues. Why Java? Course Overview. Hello, World! in Java Organisational issues Inf1-OOP Course Overview Perdita Stevens, adapting earlier version by Ewan Klein School of Informatics January 11, 2014 Why Java? Hello, World! in Java Built-in Types Integers Floating-Point

More information

CLASSES AND OBJECTS. Fundamentals of Computer Science I

CLASSES AND OBJECTS. Fundamentals of Computer Science I CLASSES AND OBJECTS Fundamentals of Computer Science I Outline Primitive types Creating your own data types Classes Objects Instance variables Instance methods Constructors Arrays of objects A Foundation

More information

Java Programming. MSc Induction Tutorials Stefan Stafrace PhD Student Department of Computing

Java Programming. MSc Induction Tutorials Stefan Stafrace PhD Student Department of Computing Java Programming MSc Induction Tutorials 2011 Stefan Stafrace PhD Student Department of Computing s.stafrace@surrey.ac.uk 1 Tutorial Objectives This is an example based tutorial for students who want to

More information

COMP 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 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

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals 1 Recall From Last Time: Java Program import java.util.scanner; public class EggBasketEnhanced { public static void main(string[]

More information

Admin. CS 112 Introduction to Programming. Recap: OOP Analysis. Software Design and Reuse. Recap: OOP Analysis. Inheritance

Admin. CS 112 Introduction to Programming. Recap: OOP Analysis. Software Design and Reuse. Recap: OOP Analysis. Inheritance Admin CS 112 Introduction to Programming q Class project Inheritance Yang (Richard) Yang Computer Science Department Yale University 308A Watson, Phone: 432-6400 Email: yry@cs.yale.edu 2 Recap: OOP Analysis

More information

Inf1-OOP. Textbooks. Who and What. Organizational Issues. Why Java? Course Overview. Hello, World! in Java. Ewan Klein, Perdita Stevens

Inf1-OOP. Textbooks. Who and What. Organizational Issues. Why Java? Course Overview. Hello, World! in Java. Ewan Klein, Perdita Stevens Organizational Issues Inf1-OOP Course Overview Ewan Klein, Perdita Stevens School of Informatics January 12, 2013 Why Java? Hello, World! in Java Built-in Types Integers Floating-Point Numbers Type Conversion

More information

A Foundation for Programming

A Foundation for Programming 2.1 Functions A Foundation for Programming any program you might want to write objects functions and modules build bigger programs and reuse code graphics, sound, and image I/O arrays conditionals and

More information

3.2 Creating Data Types

3.2 Creating Data Types 1 3.2 Creating Data Types Data Types Data type. Set of values and operations on those values. Basic types. Data Type boolean int String Set of Values true, false -2 31 to 2 31-1 sequence of Unicode characters

More information

Java By Abstraction - Test-B (Chapters 1-6)

Java By Abstraction - Test-B (Chapters 1-6) Java By Abstraction - Test-B (Chapters 1-6) Last Name First Name Do not write below this line B (60%) A (40%) TOTAL String Methods (invoke on a string s) boolean equals(string t) Returns true if s and

More information

Lecture 2. COMP1406/1006 (the Java course) Fall M. Jason Hinek Carleton University

Lecture 2. COMP1406/1006 (the Java course) Fall M. Jason Hinek Carleton University Lecture 2 COMP1406/1006 (the Java course) Fall 2013 M. Jason Hinek Carleton University today s agenda a quick look back (last Thursday) assignment 0 is posted and is due this Friday at 2pm Java compiling

More information

AP Computer Science. Strings. Credit: Slides are modified with permission from Barry Wittman at Elizabethtown College

AP Computer Science. Strings. Credit: Slides are modified with permission from Barry Wittman at Elizabethtown College Strings AP Computer Science Credit: Slides are modified with permission from Barry Wittman at Elizabethtown College This work is licensed under an Attribution-NonCommercial-ShareAlike 3.0 Unported License

More information

CISC 1115 (Science Section) Brooklyn College Professor Langsam. Assignment #5

CISC 1115 (Science Section) Brooklyn College Professor Langsam. Assignment #5 CISC 1115 (Science Section) Brooklyn College Professor Langsam Assignment #5 An image is made up of individual points, known as pixels. Thus if we have an image with a resolution of 100 x 100, each pixel

More information

String is a Class; Quoted Text is an Object

String is a Class; Quoted Text is an Object String is a Class; Quoted Text is an Object String s = "abc d"; Indexed characters: 01234 abc d s.length() is 5 s.charat(2) is 'c' s.substring(2) is "c d" s.substring(1,3) is "bc" @3e9cff "abc d" length()

More information

8/25/17. Demo: Create application. CS2110, Recita.on 1. Arguments to method main, Packages, Wrapper Classes, Characters, Strings.

8/25/17. Demo: Create application. CS2110, Recita.on 1. Arguments to method main, Packages, Wrapper Classes, Characters, Strings. CS2110, Recita.on 1 Arguments to method main, Packages, Wrapper Classes, Characters, Strings Demo: Create application To create a new project that has a method called main with a body that contains the

More information

DATA TYPES AND EXPRESSIONS

DATA TYPES AND EXPRESSIONS DATA TYPES AND EXPRESSIONS Outline Variables Naming Conventions Data Types Primitive Data Types Review: int, double New: boolean, char The String Class Type Conversion Expressions Assignment Mathematical

More information

! 52 playing cards in a deck. ! 5 thousand undergrads at Princeton. ! 1 million characters in a book. ! 10 million audio samples in an MP3 file.

! 52 playing cards in a deck. ! 5 thousand undergrads at Princeton. ! 1 million characters in a book. ! 10 million audio samples in an MP3 file. Arrays 1.4 Arrays This lecture. Store and manipulate huge quantities of data. Array. Indexed sequence of values of the same type. Examples.! 52 playing cards in a deck.! 5 thousand undergrads at Princeton.!

More information

We now start exploring some key elements of the Java programming language and ways of performing I/O

We now start exploring some key elements of the Java programming language and ways of performing I/O We now start exploring some key elements of the Java programming language and ways of performing I/O This week we focus on: Introduction to objects The String class String concatenation Creating objects

More information

Debugging [continued]

Debugging [continued] 1 Debugging [continued] Admiral Grace Murray Hopper http://www.history.navy.mil/photos/images/h96000/h96566kc.htm 2 Debugging Your Program Debugging Your Program. [summary] 1. Edit the program (type in

More information

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

Programs as Models. Procedural Paradigm. Class Methods. CS256 Computer Science I Kevin Sahr, PhD. Lecture 11: Objects CS256 Computer Science I Kevin Sahr, PhD Lecture 11: Objects 1 Programs as Models remember: we write programs to solve realworld problems programs act as models of the real-world problem to be solved one

More information

CIS 1068 Design and Abstraction Spring 2017 Midterm 1a

CIS 1068 Design and Abstraction Spring 2017 Midterm 1a Spring 2017 Name: TUID: Page Points Score 1 28 2 18 3 12 4 12 5 15 6 15 Total: 100 Instructions The exam is closed book, closed notes. You may not use a calculator, cell phone, etc. i Some API Reminders

More information

More non-primitive types Lesson 06

More non-primitive types Lesson 06 CSC110 2.0 Object Oriented Programming Ms. Gnanakanthi Makalanda Dept. of Computer Science University of Sri Jayewardenepura More non-primitive types Lesson 06 1 2 Outline 1. Two-dimensional arrays 2.

More information

AWT COLOR CLASS. Introduction. Class declaration. Field

AWT COLOR CLASS. Introduction. Class declaration. Field http://www.tutorialspoint.com/awt/awt_color.htm AWT COLOR CLASS Copyright tutorialspoint.com Introduction The Color class states colors in the default srgb color space or colors in arbitrary color spaces

More information

10. Creating Data Types

10. Creating Data Types COMPUTER SCIENCE S E D G E W I C K / W A Y N E 10. Creating Data Types Section 3.2 http://introcs.cs.princeton.edu COMPUTER SCIENCE S E D G E W I C K / W A Y N E 10. Creating Data Types Overview Point

More information

Discover how to get up and running with the Java Development Environment and with the Eclipse IDE to create Java programs.

Discover how to get up and running with the Java Development Environment and with the Eclipse IDE to create Java programs. Java SE11 Development Java is the most widely-used development language in the world today. It allows programmers to create objects that can interact with other objects to solve a problem. Explore Java

More information

Lesson:9 Working with Array and String

Lesson:9 Working with Array and String Introduction to Array: Lesson:9 Working with Array and String An Array is a variable representing a collection of homogeneous type of elements. Arrays are useful to represent vector, matrix and other multi-dimensional

More information

Strings. Strings and their methods. Mairead Meagher Dr. Siobhán Drohan. Produced by: Department of Computing and Mathematics

Strings. Strings and their methods. Mairead Meagher Dr. Siobhán Drohan. Produced by: Department of Computing and Mathematics Strings Strings and their methods Produced by: Mairead Meagher Dr. Siobhán Drohan Department of Computing and Mathematics http://www.wit.ie/ Topics list Primitive Types: char Object Types: String Primitive

More information

Slide 1 CS 170 Java Programming 1 Multidimensional Arrays Duration: 00:00:39 Advance mode: Auto

Slide 1 CS 170 Java Programming 1 Multidimensional Arrays Duration: 00:00:39 Advance mode: Auto CS 170 Java Programming 1 Working with Rows and Columns Slide 1 CS 170 Java Programming 1 Duration: 00:00:39 Create a multidimensional array with multiple brackets int[ ] d1 = new int[5]; int[ ][ ] d2;

More information

3.2 Creating Data Types

3.2 Creating Data Types Data Types 3.2 Creating Data Types Data type. Set of values and operations on those values. Basic types. Data Type boolean int String Set of Values true, false -2 31 to 2 31-1 sequence of Unicode characters

More information

Introduction to Computer Science Unit 2. Notes

Introduction to Computer Science Unit 2. Notes Introduction to Computer Science Unit 2. Notes Name: Objectives: By the completion of this packet, students should be able to describe the difference between.java and.class files and the JVM. create and

More information

Introduction to Programming Using Java (98-388)

Introduction 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 information

Computer Science. 9. Creating Data Types. Computer Science COMPUTER SCIENCE. Section 3.2.

Computer Science. 9. Creating Data Types. Computer Science COMPUTER SCIENCE. Section 3.2. COMPUTER SCIENCE S E D G E W I C K / W A Y N E PA R T I : P R O G R A M M I N G I N J AVA Computer Science Computer Science An Interdisciplinary Approach Section 3.2 ROBERT SEDGEWICK K E V I N WAY N E

More information

Class definition. complete definition. public public class abstract no instance can be created final class cannot be extended

Class definition. complete definition. public public class abstract no instance can be created final class cannot be extended JAVA Classes Class definition complete definition [public] [abstract] [final] class Name [extends Parent] [impelements ListOfInterfaces] {... // class body public public class abstract no instance can

More information

Introduction to Computer Science Unit 2. Notes

Introduction to Computer Science Unit 2. Notes Introduction to Computer Science Unit 2. Notes Name: Objectives: By the completion of this packet, students should be able to describe the difference between.java and.class files and the JVM. create and

More information

Strings. Strings, which are widely used in Java programming, are a sequence of characters. In the Java programming language, strings are objects.

Strings. Strings, which are widely used in Java programming, are a sequence of characters. In the Java programming language, strings are objects. Strings Strings, which are widely used in Java programming, are a sequence of characters. In the Java programming language, strings are objects. The Java platform provides the String class to create and

More information

Full file at

Full file at Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class

More information

1.4 Arrays. A Foundation for Programming. Many Variables of the Same Type. Arrays. !!! any program you might want to write

1.4 Arrays. A Foundation for Programming. Many Variables of the Same Type. Arrays. !!! any program you might want to write A Foundation for Programming 1.4 Arrays any program you might want to write objects functions and modules graphics, sound, and image I/O arrays store and manipulate huge quantities of data conditionals

More information

Informatics 1: Data & Analysis

Informatics 1: Data & Analysis Informatics 1: Data & Analysis Lecture 5: Relational Algebra Ian Stark School of Informatics The University of Edinburgh Tuesday 31 January 2017 Semester 2 Week 3 https://blog.inf.ed.ac.uk/da17 Tutorial

More information

Using Java Classes Fall 2018 Margaret Reid-Miller

Using Java Classes Fall 2018 Margaret Reid-Miller Using Java Classes 15-121 Fall 2018 Margaret Reid-Miller Today Strings I/O (using Scanner) Loops, Conditionals, Scope Math Class (random) Fall 2018 15-121 (Reid-Miller) 2 The Math Class The Math class

More information

COS 126 Exam 2 Review Part 1

COS 126 Exam 2 Review Part 1 COS 126 Exam 2 Review Part 1 Programming Exam 2 Part 1 (ADT) Q. Can you implement a simple abstract data type? Example (Fall 2016). Part 1. Implement a data type ColorHSB.java for HSB colors. This time,

More information

A Founda4on for Programming

A Founda4on for Programming 3.1 Objects LOGO STYLE GUIDE Schools within the University Introduction to Programming in Java: An Interdisciplinary Approach Robert Sedgewick and Kevin Wayne Copyright 2002 2010 3/16/14 11:29 PM A Founda4on

More information

Lecture 4. Strings, Wrappers, & Containers

Lecture 4. Strings, Wrappers, & Containers Lecture 4 Strings, Wrappers, & Containers Announcements for This Lecture Readings pp. 175 181 Sections 2.5, 3.1.2-3.1.3 Also Section 5.2 PLive (optional): Lesson 2-5 Lessons 5-1 and 5-2 Assignments Assignment

More information

Inf1-OP. Course Overview. Volker Seeker, adapting earlier version by Perdita Stevens and Ewan Klein. February 26, School of Informatics

Inf1-OP. Course Overview. Volker Seeker, adapting earlier version by Perdita Stevens and Ewan Klein. February 26, School of Informatics Inf1-OP Course Overview Volker Seeker, adapting earlier version by Perdita Stevens and Ewan Klein School of Informatics February 26, 2018 Administrative Stuff Who to contact for help? Lecturer: Volker

More information

Who and what can help? Inf1-OP. Lecturer: Timothy Hospedales TA: Natalia Zon

Who and what can help? Inf1-OP. Lecturer: Timothy Hospedales TA: Natalia Zon Who and what can help? Inf1-OP Lecturer: Timothy Hospedales TA: Natalia Zon Course Overview Web: http://www.inf.ed.ac.uk/teaching/ courses/inf1/op/ Timothy Hospedales, adapting earlier version by Perdita

More information

1.1 Your First Program

1.1 Your First Program 1.1 Your First Program Introduction to Programming in Java: An Interdisciplinary Approach Robert Sedgewick and Kevin Wayne Copyright 2002 2010 5/20/2013 9:37:22 AM Why Programming? Why programming? Need

More information

McGill University School of Computer Science COMP-202A Introduction to Computing 1

McGill University School of Computer Science COMP-202A Introduction to Computing 1 McGill University School of Computer Science COMP-202A Introduction to Computing 1 Midterm Exam Thursday, October 26, 2006, 18:00-20:00 (6:00 8:00 PM) Instructors: Mathieu Petitpas, Shah Asaduzzaman, Sherif

More information

MODULE 02: BASIC COMPUTATION IN JAVA

MODULE 02: BASIC COMPUTATION IN JAVA MODULE 02: BASIC COMPUTATION IN JAVA Outline Variables Naming Conventions Data Types Primitive Data Types Review: int, double New: boolean, char The String Class Type Conversion Expressions Assignment

More information

Object-Oriented Programming Classes, Objects, Variables

Object-Oriented Programming Classes, Objects, Variables Object-Oriented Programming Classes, Objects, Variables Ewan Klein School of Informatics Inf1 :: 2009/10 Ewan Klein (School of Informatics) Object-Oriented ProgrammingClasses, Objects, Variables Inf1 ::

More information

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I

BASIC 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 information

CSCI 135 Exam #1 Fundamentals of Computer Science I Fall 2012

CSCI 135 Exam #1 Fundamentals of Computer Science I Fall 2012 CSCI 135 Exam #1 Fundamentals of Computer Science I Fall 2012 Name: This exam consists of 6 problems on the following 7 pages. You may use your two-sided hand-written 8 ½ x 11 note sheet during the exam.

More information

ANSWERS. Birkbeck (University of London) Software and Programming 1 In-class Test Feb Student Name Student Number. Answer all questions

ANSWERS. Birkbeck (University of London) Software and Programming 1 In-class Test Feb Student Name Student Number. Answer all questions Birkbeck (University of London) Software and Programming 1 In-class Test 1.1 9 Feb 2017 Student Name Student Number Answer all questions 1. Consider the following sequence of Java statements: int m = 3;

More information

if (x == 0); System.out.println( x=0 ); if (x = 0) System.out.println( x=0 );

if (x == 0); System.out.println( x=0 ); if (x = 0) System.out.println( x=0 ); Sample Final Exam 1. Evaluate each of the following expressions and show the result and data type of each: Expression Value Data Type 14 % 5 1 / 2 + 1 / 3 + 1 / 4 4.0 / 2.0 Math.pow(2.0, 3.0) (double)(2

More information

Lecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University

Lecture 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 information

COMPUTER SCIENCE. 4. Arrays. Section 1.4.

COMPUTER SCIENCE. 4. Arrays. Section 1.4. COMPUTER SCIENCE S E D G E W I C K / W A Y N E 4. Arrays Section 1.4 http://introcs.cs.princeton.edu Basic building blocks for programming any program you might want to write objects functions and modules

More information

TeenCoder : Java Programming (ISBN )

TeenCoder : Java Programming (ISBN ) TeenCoder : Java Programming (ISBN 978-0-9887070-2-3) and the AP * Computer Science A Exam Requirements (Alignment to Tennessee AP CS A course code 3635) Updated March, 2015 Contains the new 2014-2015+

More information

York University Fall 2001 / Test #1 Department of Computer Science

York University Fall 2001 / Test #1 Department of Computer Science York University all 2001 / est #1 Department of Computer Science COSC1020.01 his is a closed book, 90-minute test. ill in your personal data below and wait. You may use pen or pencil but answers written

More information

Objectives of CS 230. Java portability. Why ADTs? 8/18/14

Objectives of CS 230. Java portability. Why ADTs?  8/18/14 http://cs.wellesley.edu/~cs230 Objectives of CS 230 Teach main ideas of programming Data abstraction Modularity Performance analysis Basic abstract data types (ADTs) Make you a more competent programmer

More information

Programming Language Concepts: Lecture 2

Programming 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 information

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

CS 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 information

CSCI 136 Data Structures & Advanced Programming. Lecture 3 Fall 2018 Instructors: Bill & Bill

CSCI 136 Data Structures & Advanced Programming. Lecture 3 Fall 2018 Instructors: Bill & Bill CSCI 136 Data Structures & Advanced Programming Lecture 3 Fall 2018 Instructors: Bill & Bill Administrative Details Lab today in TCL 217a (and 216) Lab is due by 11pm Sunday Lab 1 design doc is due at

More information

4. Java Project Design, Input Methods

4. Java Project Design, Input Methods 4-1 4. Java Project Design, Input Methods Review and Preview You should now be fairly comfortable with creating, compiling and running simple Java projects. In this class, we continue learning new Java

More information

AP Computer Science Chapter 10 Implementing and Using Classes Study Guide

AP 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 information

Graphics and Java 2D Introduction OBJECTIVES. One picture is worth ten thousand words.

Graphics and Java 2D Introduction OBJECTIVES. One picture is worth ten thousand words. 1 2 12 Graphics and Java 2D One picture is worth ten thousand words. Chinese proverb Treat nature in terms of the cylinder, the sphere, the cone, all in perspective. Paul Cézanne Colors, like features,

More information

CompuScholar, Inc. 9th - 12th grades

CompuScholar, Inc. 9th - 12th grades CompuScholar, Inc. Alignment to the College Board AP Computer Science A Standards 9th - 12th grades AP Course Details: Course Title: Grade Level: Standards Link: AP Computer Science A 9th - 12th grades

More information

Designing data types. Overview. Object Oriented Programming. Alan Kay. Object Oriented Programming (OOP) Data encapsulation. Checking for equality

Designing data types. Overview. Object Oriented Programming. Alan Kay. Object Oriented Programming (OOP) Data encapsulation. Checking for equality Designing data types Overview Object Oriented Programming (OOP) Data encapsulation Important consideration when designing a class Access modifiers Immutability, preventing change to a variable Checking

More information

Unit 4: Classes and Objects Notes

Unit 4: Classes and Objects Notes Unit 4: Classes and Objects Notes AP CS A Another Data Type. So far, we have used two types of primitive variables: ints and doubles. Another data type is the boolean data type. Variables of type boolean

More information