2 Pages

4l06

Course: CPS 100, Fall 2009
School: Duke
Rating:
 
 
 
 
 

Word Count: 480

Document Preview

and Inheritance Interfaces Single inheritance in Java Inheritance models an "is-a" relationship A class can extend only one class in Java A dog is a mammal, an ArrayList is a List, a square is a shape, Write general programs to understand the abstraction, advantages? void doShape(Shape s) { System.out.println(s.area()); System.out.println(s.perimeter()); s.expand(2.0); } All classes...

Register Now

Unformatted Document Excerpt

Coursehero >> North Carolina >> Duke >> CPS 100

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
and Inheritance Interfaces Single inheritance in Java Inheritance models an "is-a" relationship A class can extend only one class in Java A dog is a mammal, an ArrayList is a List, a square is a shape, Write general programs to understand the abstraction, advantages? void doShape(Shape s) { System.out.println(s.area()); System.out.println(s.perimeter()); s.expand(2.0); } All classes extend Object --- it's the root of the inheritance hierarchy tree Can extend something else (which extends Object), why? Why do we use inheritance in designing programs/systems? But a dog is also a quadruped, how can we deal with this? Facilitate code-reuse (what does that mean?) Ability to specialize and change behavior o If I could change how method foo() works, bar() is ok Design methods to call ours, even before we implement o Hollywood principle: don't call us, 6.2 CompSci 100E 6.1 CompSci 100E Multiple Interfaces Inheritance Example public class UtilRecord extends Record { // assumes Records fields are protected, not private private String kind; public UtilRecord(){ this("", "", 0, 0, "", ""); } public UtilRecord(String a, String f, int s, int o, String e, String k) { super(a, f, s, o, e); kind = k; } /* etc */ 6.4 Classes (and interfaces) can implement multiple interfaces A dog is a mammal, a quadruped, a pet How come canine is different? What behavior do quadrupeds have? Pets have? An interface specifies the name (and signature) of methods No implementation, no state/fields Yes for this constants In course, by convention, we'll often use interfaces Emphasize design before implementation Use abstract/default classes for code reuse, state CompSci 100E 6.3 CompSci 100E Comparable and Comparator Comparable Example public class Record implements Comparable { public Record(String a, String f, int s, int o, String e) { . . . } public Record(Record rec) { . . . } int compareTo(Record r) { // comparision code goes here // set n to neg # if <, 0 if ==, and pos # if > return n } CompSci 100E 6.6 Both are interfaces, there is no default implementation Contrast with .equals(), default implementation? Contrast with .toString(), default? In its own .java file, nothing wrong with that Private, used for implementation and not public behavior o Use a nested class, then decide on static or non-static o Non-static is part of an object, access inner fields Sort, Sets, Maps (in the future) Where do we define a...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Duke - CPS - 100
Java 5 New Features Generics Generics Enhanced for loop Autoboxing/unboxing Typesafe enums Other Allows classes to store objects whose type is irrelevant to storing class, while allowing type-safe retrieval E.g., Collection SyntaxArr
Duke - CPS - 100
Binary TreesFrom doubly-linked lists to binary treesLinked lists: efficient insertion/deletion, inefficient search ArrayList: search can be efficient, insertion/deletion not Binary trees: efficient insertion, deletion, and search trees used i
Duke - CPS - 100
Balanced Binary Search TreesBalanced Binary Search TreesPathological BST Keeping BSTrees Balanced Insert nodes from ordered list Search: O(_) ? Binary Tree is balanced if height of left and right subtree differ by no more than one, recurs
BYU - CATALOG - 0204
Sy Syms School of Businessy Syms School of Business offers business programs for undergraduate men and women. It was established in 1987 through major gifts by Sy Syms, a member of the Universitys Board of Trustees, and other business leaders. The S
BYU - CATALOG - 0204
Irving I.Stone Beit Midrash ProgramEstablished in 1995, the Irving I. Stone Beit Midrash Program offers undergraduate men a structured Jewish studies program designed for students with special scheduling needs and interests. It maintains a high l
Duke - CPS - 100
Data and InformationOrganizing Data: ideas and issues!How and why do we organize data? Differences between data and information? What about knowledge?!Often there is a time/space tradeoff ! If we use more space (memory) we can solve a data/ i
Duke - CPS - 100
Loop Invariants!Bean Can game! !!Want to reason about the correctness of a proposed iterative solution Loop invariants provide a means to effectively about the correctness of codeCan contains N black beans and M white beans initially Emptie
Duke - CPS - 108
LibrariesqIn C+ it's possible to create static libraries and shared libraries Static libraries (end in .a) are combined/linked into an executable Executables are large. If library is updated in a binary compatible way, programs still need to be
Duke - CPS - 108
Overloading operatorsqWhy overload operators? (=, =, &lt;, &gt;, +=, ) notational convenience match user expectations because we can (except : and . and .*) Remember, overloaded operators are just function calls operands are parameters, thus subject
Duke - CPS - 108
Software DesignSee Alan Cooper, The Essentials of User Interface Design q who designs the software?Implentation modelworsebetterusers modelqqImplementation is view of software developer, users view is mental model, software designer ha
Duke - CPS - 100
Backtracking, Search, HeuristicsqClassic problem: N queensqMany problems require an approach similar to solving a maze Certain mazes can be solved using the &quot;right-hand&quot; rule Other mazes, e.g., with islands, require another approach If you h
Duke - CPS - 100
Heaps, Priority Queues, CompressionqPriority QueueqCompression is a high-profile application .zip, .mp3, .jpg, .gif, .gz, Why is compression important? Whats the difference between compression for .mp3 files and compression for .zip files?
Duke - CPS - 100
cps 100 &quot;Green I do not Lack&quot; as sung to the tune of Sir-mix alot's &quot; Baby's got back&quot; Intro-oh my god, Joey look at this apt it is so big uhh it looks like one of those big time programs but u know who understands those programs they only work becau
Duke - CPS - 140
CPS 140Project 3 Project Due: Saturday, April 24, 8am 50 pointsSpring 1999No LATE projects accepted after Thursday, April 29, 8am.The purpose of this assignment is to write an interpretor for the LSYS programming language see the project 1 and
Duke - CPS - 140
Section: Turing Machines Review Regular Languages FA, RG, RE recognize Context Free Languages PDA, CFG recognize1DFA:input tape a tape head current state 0 5 4 3 1 2 b b a bhead moves2Turing Machine:input tape a tape head current state
Duke - CPS - 140
CPS 140 - Mathematical Foundations of CS Dr. S. Rodger Section: The Structure of a Compiler 1.1 What is a Compiler? I. Translator Definition: program in language X - translator for X - program in language YExamples: Source Language High Level Assem
Duke - CPS - 140
CPS 140 - Mathematical Foundations of CS Dr. S. Rodger Section: Transforming Grammars Ch. 6 handoutMethods for Transforming Grammars Read Ch 6 in Linz BookWe will consider CFL without . It would be easy to add to any grammar by adding a new start
Duke - CPS - 140
Section: Turing Machines - Building Blocks 1. Given Turing Machines M1 and M2 Notation for Run M1 Run M2M1 M2SHSHM1M2SHz;z,Rz;z,LSHz represents any symbol in12. Given Turing Machines M1 and M2M1 M2SHSHM1x
Duke - CPS - 140
Grammars unrestricted grammarAutomata Turing machineAll Languages Rec. Enum. Lang.CFGContext-free Lang. Regular Lang.pushdown automataregular grammarfinite automata1Power of Machines automata Can do? FA PDA TM integers arith exprC
Duke - CPS - 140
CPS 140 - Mathematical Foundations of CS Dr. Susan Rodger Section: Introduction Ch. 1 handoutgrammarsall languagesautomataunrestricted grammarrecursively enumerable languagesTuring machineCFGcontext-free languages regular languagesp
Duke - CPS - 140
CPS 140Project 2 Due: Tuesday, March 25 50 pointsSpring 2003The purpose of this assignment is to write a parser for the SAPL programming language (see the project 1 handout for a description of the tokens in the SAPL programming language). Your
Duke - CPS - 140
Section: Recursively Enumerable Languages1Denition: A language L is recursively enumerable if there exists a TM M such that L=L(M).recursively enumerable languages context-free languages regular languagesDenition: A language L is recursive if
Duke - CPS - 140
Section: Pushdown Automata Ch. 7 - Pushdown Automata A DFA=(Q,q0,F)input tape a a tape head b b a b head movescurrent state 0 11Modify DFA by adding a stack. New machine is called Pushdown Automata (PDA).input tapeaa tape headaabb
Duke - CPS - 140
Section: Properties of Regular Languages Example L = {anban | n &gt; 0}Closure Properties A set is closed over an operation if L1, L2 class L1 op L2 = L3 L3 class1L1={x | x is a positive even integer} L is closed under addition? multiplication?
Duke - CPS - 140
CPS 140Homework 5 Due: Tuesday, Mar. 30 22 pointsSpring 1999On homework, you may discuss with other students in the course about how to solve a problem, but the write-up should be your own. You must include the names of any students you consult
Duke - CPS - 140
CPS 140 - Mathematical Foundations of CS Dr. S. Rodger Section: The Structure of a Compiler 1.1 What is a Compiler? I. Translator Definition: program in translator program in language - for - language X X Y1Examples: Source Object Language Langua
Duke - CPS - 140
CPS 140Lab 2 Due: Thursday, March. 25, 8pm 20 pointsSpring 1999Problem:Using JFLAP, construct pushdown automata for the following languages. NOTE: If you have problems typing Z in the labels, then instead use little z and push it onto the stac
Duke - CPS - 140
Your id was mailed to you.Grades as of 5/9/99id finex exam1 exam2 proj2 proj3 lab1 lab2 120 100 100 50 50 26 20 =11 81.00 81.50 77.00 40.00 45.00 26.00 19.00 15 106.50 93.00 95.00 45.00
Duke - CPS - 237
a V o dA V r V }t r $ o trc &amp;V sH V V b b 5b s( b b b b b b 5 V V tH d b 2 b b b A( V c V trfV V
Duke - CPS - 237
Probability and Algorithms Leonard J. Schulman Notes for lecture 12, Feb 24, 2003. Sampling graph colorings.Caltech CS150, Winter 2003 Scribe: Wonjin JangLet be the number of vertices and be the max degree in G. We wish to sample -colorings unifo
Duke - CPS - 237
Quantum Computing Lecture 14a (notes on QEC)Michele MoscaClassical Error Correcting CodesSuppose errors in our physical system for storing 0 and 1 cause each physical bit to be toggled independently with probability p We can reduce the probabili
Duke - CPS - 140
Section: LL Parsing LL(k) Parser: top-down parser - starts with start symbol on stack, and repeatedly replace nonterminals until string is generated. predictive parser - predict next rewrite rule rst L of LL means - read input string left to right
Duke - CPS - 210
Security (part 1)CPS210 Spring 2006Current Forensic MethodsManual inspection of existing logs System, application logsNot enough informationNetwork logMay be encryptedDisk imageOnly shows final stateMachine level logs (ReVirt)No semanti
Duke - CPS - 004
Computer Science 4: Java for Video Gameswww.cs.duke.edu/education/courses/spring06/cps004/ Instructors Dietolf (Dee) Ramm D226 LSRC dr@cs.duke.edu Robert Duvall D228 LSRC rcd@cs.duke.eduCompSci 44.1Introduction Administrative material Int
Duke - CPS - 004
JavadocCompSci 4Javadoc27jd.1The Plan What is Javadoc? Writing Javadoc comments Using the Javadoc tool PracticeCompSci 4Javadoc27jd.2What is Javadoc?Javadoc is a way to comment your code that enables automatic generation of web
Duke - CPS - 004
Computer Science 4: Java for Video Gameswww.cs.duke.edu/education/courses/spring06/cps004/ Instructors Dietolf (Dee) Ramm D226 LSRC dr@cs.duke.edu Robert Duvall D228 LSRC rcd@cs.duke.eduIntroduction Administrative material Introduction thinki
Duke - CPS - 004
The Plan Graphics Hardware Coordinate System Built-in Shapes User-defined Shapes Sprites and Shapes Making a SpriteCompSci 45.1CompSci 45.2HardwareCoordinate Systems Monitor Resolutions (640x480, 800x600, 1280x1024) Bit
Duke - CPS - 001
Todays topics!Write Your Names(or just exercise your curiosity)!Complexity &quot; Notes from Mason Matthews &quot; Great Ideas Ch. 13 Computability &quot; Great Ideas Ch. 15, Brookshear Ch. 11CPS 00111.1CPS 00111.2What is Computer Science?What c
Duke - CPS - 001
KeyEscrowasaSecurity andRecoveryDevicePresented by: Kevin Ji, Maura Tresch, Eyan Townsend, Whitney Anderson, Turner Rooney, Dan Tulley WhatisaKeyEscrowSystemKey Escrow is the use of a third party (the escrow service) to save and catalog private
UC Davis - LOG - 0503
A Homage toAlfred SchnittkeIrina Schnittke, piano Tatyana Grindenko, violin Alexander Ivashkin, cello Wednesday 30 March 2005, 7.30pmConcert in aid of the Alfred Schnittke Archive in London Sponsored by the Centre for Russian Music, Goldsmiths C
UC Davis - ATT - 0503
A Homage toAlfred SchnittkeIrina Schnittke, piano Tatyana Grindenko, violin Alexander Ivashkin, cello Wednesday 30 March 2005, 7.30pmConcert in aid of the Alfred Schnittke Archive in London Sponsored by the Centre for Russian Music, Goldsmiths C
Duke - STA - 205
Midterm ExaminationSTA 205: Probability and Measure Theory Wednesday, 2005 Mar 9, 2:50-4:05 pmThis is a closed-book examination. You may use a single one-sided sheet of prepared notes, if you wish, but you may not share materials. If a question se
Duke - STA - 216
Bayesian Hypothesis Testing in GLMs: One-Sided and Ordered Alternatives Often interest may focus on comparing a null hypothesis of no dierence between groups to an ordered restricted alternative. For example, we may have a k level ordered categoric
Duke - STA - 103
STA103Probability/Statistical InferenceJenises contact infoInstructor: Jenise Swall Office: 221 Old Chem Bldg. Phone: 684-4608 Office hours: Wed. 9:30PM-10:30PM, Thu. 1:30PM-2:30PM jenise@stat.duke.eduTA contact infoChristine KohnenMickel
Duke - STA - 242
Sta242/Env255, Week 3, 1/23/001Sta242/Env255, Week 3, 1/23/002Week 3: Simple Linear Regression1-way ANOVA: Week 2 Plant ExampleLast class: One-way ANOVA modelsfertilizer levels.Week 3 Reading: Chapter 7, Statistical Sleuth, plus all c
Duke - STA - 293
STA 293B/BGT 08 Expression Analysis Aymetrix expression data See Aymetrix tutorial Expression summaries: AD and ALR, and other information Array normalisation; Hybridisation problems - low levels of intensity One gene: Sample statistics, summari
Duke - STA - 242
6.63 15.04 14.26 15.56 16.83 16.98 14.88 14.37 14.23 15.15 15.74 26.15 26.52 25.84 25.69 26.08 25.32 25.95 26.95 25.57 29.57 36.99 38.77 39.59 37.07 37.7 37.22 37.45 37.89 38.99 38.79 49.35 48.21 48.63 410.33 48.51
Duke - STA - 242
STA242/ENV255 Quiz, 3/7/01 Name:_Page 1 of 3 Total Points (out of 15):_The questions below refer to the bird energy data described on this page. The results below summarize a study of the amount of energy metabolized (in calories) by two similar
Duke - STA - 244
STA2441/22/2001Homework 2Due 1/29/2001 1. (From CB 11.40) Consider the standard simple linear model with normal errors that has been re-parameterized as Yt = Y + t + where t = (X X) so that Y = Y and are independent. Extend Sches procedure
Duke - STA - 242
Week 5, Lec. 1, 2/5/02Week 5, Lec. 1, 2/5/02Regression Parameter EstimatesResiduals: Min 1Q Median 3Q Max -0.339 -0.1071 -0.01023 0.1361 0.3588 Coefficients: (Intercept) log(time) Value Std. Error 6.8115 0.1113 -0.5350 0.0609 t value Pr(&gt;|t|) 6
Duke - STA - 242
W X b i C2f6&quot;egvCvrdvh6iCvY2yvtrr2vCvyr0egvYCgEl2lv ie b u b u b u x w q i x x e b u b n q i ie e e e X X be u b s i u s u b b u v V Cgvvd&amp;v2!add6Y{ V|Xf CYElevCbhCvuYxfwvrCgr)vCy2v02)V|V 2egv26$vEvd b b b
Duke - STA - 103
( {~ m { zyG}~ 0 G ~ t 0y k m| { 0~ p~m { 0y k { Y ym d dy ~ k { ym d k 2X B T4 RXaa22 D h 0c`C0bbSSIpap4h D2 B q { T4 2 B4 h 2 8 T4 2 22 D 2R Ta H F h h H 2 B4 2 42 1 rW) }0y YbICwD#Q`CSSYSPpHpD`AICQ8 k 5@8 ( Y}pm Y0Y
Duke - STA - 244
APMAM APSAB APSLAKE OPBPC OPRC OPSLAKE Y Year 9.13 3.58 3.91 4.1 7.43 6.47 54235 1948 5.28 4.82 5.2 7.55 11.11 10.26 67567 1949 4.2 3.77 3.67 9.52 12.2 11.35 66161 1950 4.6 4.46 3.93 11.14 15.15 11.13 68094 1951 7.15 4.99 4.88 16.34 20.05 22.81
Duke - STA - 244
BigMac Bread BusFare EngSal EngTax Service TeachSal TeachTax VacDays WorkHrs 31 9 1.27 44.3 44.1 280 21.8 28.2 31.9 1714 33 9 0.27 19.4 23.7 170 9.4 14.8 23.5 1792 98 23 0.09 15.4 20.3 100 2.2 4.3 17.4 2152 131 27 0.09 4.7 37.6 70 1.1 11.7 30.6 2
Duke - STA - 244
Exotic Sire Total Trt 9 1 9 1 5 1 8 2 5 1 8 3 6 1 8 4 3 2 9 1 0 2 9 2 5 2 9 3 5 2 8 4 5 3 8 1 5 3 8 2 6 3 9 3 5 3 6 4 7 4 7 1 7 4 8 2 3 4 6 3 4 4 8 4 8 5 9 1 4 5 8 2 4 5 7 3 6 5 9 4 5 6 9 1 5 6 9 2 4 6 9 3 2 6 7 4 8 7 9 1 4
Duke - STA - 244
Height Length Type 75 502 0 80 522 0 68 425 0 64 344 0 83 407 0 80 451 0 70 551 0 76 530 0 74 547 0 100 519 1 75 225 1 52 300 1 62 418 1 68 409 1 86 425 1 57 370 1 82 506 1 82 506 1 88 295 1 55 273 1 67 415 1 45 182 1 103 530 1
Duke - STA - 244
D F S W 7.2 0 0 10.404 8.2 0 0 18.161 10.3 0 0 25.778 10.1 0 0 20.511 10.7 0 0 21.87 13.3 0 0 47.186 5.1 1 0 4.447 7.2 1 0 8.682 10.2 1 0 19.511 11.3 1 0 37.682 12.6 1 0 25.775 17.1 1 0 67.363 5.1 0 1 4.02 6.5 0 1 7.504 8.4 0 1 13.391
Duke - STA - 244
BodyWt Dose LiverWt y 176 0.88 6.5 0.42 176 0.88 9.5 0.25 190 1 9 0.56 176 0.88 8.9 0.23 200 1 7.2 0.23 167 0.83 8.9 0.32 188 0.94 8 0.37 195 0.98 10 0.41 176 0.88 8 0.33 165 0.84 7.9 0.38 158 0.8 6.9 0.27 148 0.74 7.3 0.36 149 0.75 5.2
Duke - STA - 244
Age Score 15 95 26 71 10 83 9 91 15 102 20 87 18 93 11 100 8 104 20 94 7 113 9 96 10 83 11 84 11 102 10 100 12 105 42 57 17 121 11 86 10 100
Duke - STA - 102
smoke disease sex 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Duke - STA - 216
CASE STUDY: Bayesian Incidence Analyses from Cross-Sectional Data with Multiple Markers of Disease Severity Outline: 1. NIEHS Uterine Fibroid Study Design of Study Scientific Questions Difficulties 2. General Problem and Earlier Approaches 3. Baye