Review Session. CS2110 Prelim #1 3/8/15. Primitive types vs classes. Default values. Wrapper Classes (Boxing) Strings are immutable.

Size: px
Start display at page:

Download "Review Session. CS2110 Prelim #1 3/8/15. Primitive types vs classes. Default values. Wrapper Classes (Boxing) Strings are immutable."

Transcription

1 Review Session Primitive types vs classes Varialedeclarations: o int i = 5; o Animal a = new Animal( Bo ); How does == ehave? CS2 Prelim # a i Animal@x36 Animal@x36 5 name Bo Default values Wrapper Classes (Boxing) What value does a field contain when it is declared ut not instantiated? o Animal a; o Oject o; o int i; o oolean ; o char c; o doule d; //null //null // //false // \ (null yte) //. class Character contains useful methods Examples of useful static Character methods: o Character.isDigit(c) o IntCharacter.isLetter(c) Autooxing o Integer x = ; o int y = x; String literals String instantiation: Constructor: String s = new String( dog ); Literal: String s2 = dog ; Roughly equivalent, ut literal is preferred s String@x62 s2 String@x28 String@x28 String@x62 dog Strings are immutale Once a String is created, it cannot e changed Methods such as tolowercase and sustring return new Strings, leaving the original one untouched In order to modify Strings, you instead construct a new String and then reassign it to the original variale: o String name = Gries ; o name = name +, ; o name = name + David ; dog

2 String concatenation Other String info Operator + operator is called catenation, or concatenation If one operand is a String and the other isn t, the other is converted to a String Important case: Use + exp to convert exp to a String. Evaluates left to right. Common mistake: o System.out.println( sum: ); Prints sum: 56 o System.out.println( sum: + (5 + 6)); Prints sum: Always use equals to compare Strings: o str.equals(str2) Very useful methods: o length, sustring (overloaded), indexof, charat Useful methods: o lastindexof, contains, compareto D Array Review Java arrays Animal[] pets = new Animal[3]; Java arrays do not change size! pets.length is 3 pets[] = new Animal(); pets[].walk(); Why is the following illegal? pets[] = new Oject(); pets null Array@x null null 2 null Array@x A@xa A@x2 Big A@x2 A@xa Cornell Ithaca String[] = { Cornell, Ithaca ; String[] Big = Arrays.copyOf(, 4); = Big; A@x2 2 3 Cornell Ithaca 2D arrays: An array of D arrays. 2D arrays: An array of D arrays. Java only has D arrays, whose elements can also e arrays. int[][] = new int[2][3]; This array has 2 int[] arrays of length 3 each. 2 How many rows in? How many columns in row? How many columns in row?.length [].length [].length

3 2D arrays: An array of D arrays. 2D arrays: An array of D arrays. int[][] = new int[2][]; The elements of are of type int[]. int[][] = new int[2][]; [] = new int[] {,4,,3,9,3; [] = new int[] {,2,3; null null is called a ragged array Exceptions The superclass of exceptions: Throwale A Throwale instance: ArithmeticException Exceptions class Throwale: Superclass of Error and Exception Does the crashing Contains the constructors and methods Throwale() Throwale(String) class Error: A very serious prolem and should not e handled Example: StackOverflowError class Exception: Reasonale application might want to crash or handle the Exception in some way ArithmeticException@x2 Throwale detailmessage Exception RuntimeException ArithmeticException / y zero There are so many exceptions we need to organize them. Exception Throwale RuntimeException ArithmeticException Error Buling up exceptions Exceptions will ule up the call stack and crash the methods that called it. Method call: first(); Console: Exception in thread main java.lang.arithmeticexception: at Ex.third(Ex.java:) at Ex.second(Ex.java:7) at Ex.first(Ex.java:3) AE AE AE Exceptions class Ex { void first() { second(); AE = ArithmeticException void second() { third(); void third() { int c = 5/; Try-catch locks An exception will ule up the call stack and crash the methods that called it unless it is caught. catch will handle any exceptions of type Exception (and its suclasses) that happened in the try lock Console: in error class Ex { void first() { second(); void second() { try { System.out.println( in ); third(); Exceptions System.out.println( out ); catch (Exception e){ System.out.print( error ); Exception Type ArithmeticException! void third() { int c = 5/; 3

4 How to write an exception class Exceptions A Little More Geometry! Astract Classes /** An instance is an exception */ pulic class OurException extends Exception { /** Constructor: an instance with message m*/ pulic OurException(String m) { super(m); Shape x y /** Constructor: an instance with default message */ pulic OurException() { this( Default message! ); Square area() size Triangle area() ase height Circle area() radius A Partial Solution: Astract Classes Prolems not solved Astract Classes Add method area to class Shape: pulic doule area() { return ; pulic doule area() { throw new RuntimeException( area not overridden );. What is a Shape that isn t a Circle, Square, Triangle, etc? What is only a shape, nothing more specific? a. Shape s = new Shape(...); Should e disallowed 2. What if a suclass doesn t override area()? a. Can t force the suclass to override it!. Incorrect value returned or exception thrown. Solution: Astract classes Astract Classes Solution: Astract methods Astract Classes Astract class Can t e instantiated. (new Shape() illegal) pulic astract class Shape { pulic astract class Shape { Can have implemented methods, too pulic doule area() { return ; pulic astract doule area(); Astract method Suclass must override. Place astract method only in astract class. Semicolon instead of ody. 4

5 Astract Classes, Astract Methods Astract Classes. Cannot instantiate an oject of an astract class. (Cannot use new-expression). A suclass must override astract methods. (ut no multiple inheritance in Java, so ) pulic interface Whistler { methods are automatically void whistle(); pulic and astract int MEANING_OF_LIFE= 42; fields are automatically pulic, static, and final (i.e. constants) class Human extends Mammal implements Whistler { Must implement all methods in the implemented interfaces Multiple interfaces Solution: pulic interface Singer { Classes can implement several void singto(human h); interfaces! They must implement all the methods in those interfaces they implement. class Human extends Mammal implements Whistler, Singer { Interface Whistler offers promised functionality to classes Human and Parrot! Whistler Mammal Animal Bird Must implement singto(human h) and whistle() Human Dog Parrot Casting Casting Human h = new Human(); Oject o = (Oject) h; Animal a = (Animal) h; Mammal m = (Mammal) h; Singer s = (Singer) h; Whistler w = (Whistler) h; Whistler Oject Animal Mammal All point to the same memory address! Human Singer Human h = new Human(); Oject o = h; Animal a = h; Mammal m = h; Singer s = h; Whistler w = h; Automatic up-cast Forced down-cast Whistler Oject Animal Mammal Human Singer 5

6 Casting up to an interface automatically Shape implements Comparale<T> class Human implements Whistler { void listento(whistler w) {... Human h = new Human(...); Human h = new Human(...); h.listento(h); Parrot p = new Parrot(...); h.listento(p); Whistler Arg h of the call has type Human. Its value is eing stored in w, which is of type Whistler. Java does an upward cast automatically. Same thing for p of type Parrot. Oject Animal Mammal Human pulic class Shape implements Comparale<Shape> {... /** */ pulic int compareto(shape s) { doule diff= area() - s.area(); return (diff ==? : (diff <? - : +)); Beauty of interfaces String sorting Arrays.sort sorts an array of any class C, as long as C implements interface Comparale<T> without needing to know any implementation details of the class. Classes that implement Comparale: Boolean Byte Doule Integer String BigDecimal BigInteger Calendar Time Timestamp and others Arrays.sort(Oject[] ) sorts an array of any class C, as long as C implements interface Comparale<T>. String implements Comparale, so you can write String[] strings=...;... Arrays.sort(strings); During the sorting, when comparing elements, a String s compareto function is used Astract Classes vs. Astract class represents something Sharing common code etween suclasses Similarities: Can t instantiate Must implement astract methods Interface is what something can do A contract to fulfill Software Engineering purpose Four loopy questions //Precondition Initialization; // invariant: P while ( B ) { S 2. Does it stop right? Does P and!b imply the desired result? Loop Invariants. Does it start right? Does initialization make invariant P true? 3. Does repetend S make progress toward termination? 4. Does repetend S keep invariant P true? 6

7 Add elements ackwards Loop Invariants Add elements ackwards Loop Invariants Precondition Invariant Postcondition h?????? h s = sum s = sum int s = ; int h =.length-; while (h >= ) { s = s + [h]; h--; INV:??? h s = sum. Does it start right? 2. Does it stop right? 3. Does it keep the invariant true? 4. Does it make progress toward termination? Linear search time Binary search time ([..n-] is sorted) Linear search for v in an array of length n n??? worst-case time. v is not in [..n-], so linear search has to look at every element. Takes time proportional to n. expected (average) case time. If you look at all possiilities where v could e and average the numer of elements linear search has to look at, you would get close to n/2. Still time proportional to n. h= -; t= n; // invariant: P (elow) while (h < t-) { int e= (h+t)/2; if ([e] <= v) h= e; else t= e; // [..h] <= v < [t..n-] inv P: [h+..t-] starts out with n elements in it. Each iteration cuts size of [h+..t-] in half. worst-case and expected case time: log n h t n <= v? > v Insertion sort of [..n-] Selection sort of [..n-] h= ; // invariant: P (elow) while (h < n) { Push [h] down into its sorted position in [..h]; h= h+; inv P: Worst-case time for Push: h swaps Average case time for Push: h/2 swaps n- = n (n-) / 2 Worst-case and average case time: proportional to n^2 h n sorted? h= ; // invariant: P (elow) while (h < n) { Swap [h] with min value in [h..n-]; h= h+; inv P: h n sorted? To find the min value of [h..n-] takes time proportional to n - h. n + (n-) = n (n-) / 2 Worst-case and average case time: proportional to n^2 7

8 Quicksort of [..n-] Quicksort of [..n-] partition(, h, k) takes time proportional to size of [h..k] Best-case time: partition makes oth sides equal length depth: proportional to log n therefore: time n log n time n to partition time n to partition time n to partition /** Sort [h..k] */ void QS(int[], int h, int k) { if ([h..k] size < 2) return; j= partition(, h, k); // [h..j-] <= [j] <= [j+..k] QS(h, j-); QS(j+, k) Someone proved that the average or expected time for quicksort is n log n Quicksort of [..n-] What method calls are legal partition(, h, k) takes time proportional to size of [h..k] Animal an; an.m(args); Worst-case time: partition makes one side empty legal ONLY if Java can guarantee that method m exists. How to guarantee? time n to partition time n- to partition time n-2 to partition m must e declared in Animal or inherited. depth: proportional to n therefore: time n^2 Java Summary On the Resources ta of the course wesite We have selected some useful snippets We recommend going over all the slides (int) 3.2 any numer type Casting among types casts doule value 3.2 to an int any numer expression may e automatic cast narrow wider yte short int long float doule must e explicit cast, may truncate char is a numer type: (int) 'V' (char) 86 Unicode representation: 86 Page A-9, inside ack cover 'V' 48 8

9 Declaration of class Circle Multi-line comment starts with /* ends with */ /** An instance (oject) represents a circle */ pulic class Circle { Put declarations of fields, methods in class ody: { pulic: Code everywhere can refer to Circle. Called access modifier Page B-5 Precede every class with a comment Put class declaration in file Circle.java 49 Overloading Possile to have two or more methods with same name /** instance represents a rectangle */ pulic class Rectangle { private doule sideh, sidev; // Horiz, vert side lengths /** Constr: instance with horiz, vert side lengths sh, sv */ pulic Rectangle(doule sh, doule sv) { sideh= sh; sidev= sv; /** Constructor: square with side length s */ pulic Rectangle(doule s) { sideh= s; sidev= s; Lists of parameter types must differ in some way 5 Use of this this evaluates to the name of the oject in which is appears /** Constr: instance with radius radius*/ pulic Circle(doule radius) { this.radius= radius; Page B-28 Memorize this! 5 /** An instance represents a shape at a point in the plane */ pulic class Shape { private doule x, y; // top-left point of ounding ox /** Constructor: a Shape at point (x, y) */ pulic Shape (doule x, doule y) { x= x; y= y; /** return x-coordinate of ounding ox*/ pulic doule getx() { return x; /** return y-coordinate of ounding ox*/ pulic doule gety() { return y; Class Shape 52 Oject: superest class of them all Class doesn t explicitly extend another one? It automatically extends class Oject. Among other components, Oject contains: Constructor: pulic Oject() { /** return name of oject */ pulic String tostring() /** return value of this oject and o are same, i.e. of this == o */ pulic oolean equals(oject o) c.tostring() is Circle@x Page C-8 53 pulic class Circle { private doule radius; private static int t; pulic Circle(doule r) { doule r= r; radius= r; Java has 4 kinds of variale Field: declared non-static. Is in every oject of class. Default initial val depends on type, e.g. for int Class (static) var: declared static. Only one copy of it. Default initial val depends on type, e.g. for int Parameter: declared in () of method header. Created during call efore exec. of method ody, discarded when call completed. Initial value is value of corresp. arg of call. Scope: ody. Local variale: declared in method ody. Created during call efore exec. of ody, discarded when call completed. No initial value. Scope: from declaration to end of 54 lock. 9

10 Basic class Box pulic class Box { private Oject oject; pulic void set(oject o) { oject = o; pulic Oject get() { return oject; New code Box<Integer> = new Box<Integer>();.set(new Integer(35)); Integer x=.get(); parameter T (you choose name) Written using generic type pulic class Box<T> { private T oject; pulic void set(t o) { oject = o; pulic T get() { return oject; Replace type Oject everywhere y T 55 Linked Lists (These slides are from the class lectures and availale on the wesite as well) 57 Linked Lists Idea: maintain a list (2, 5, 7) like this: a a6 a8 h a v 2 v 5 v 7 next a6 next a8 next null This is a singly linked list To save space we write names like a6 instead of N@35acd Easy to insert a node in the eginning! h a a a6 a8 v 2 v 5 v 7 (2, 5, 7) next a6 next a8 next null a a6 a8 h a3 v 2 v 5 v 7 a3 next a6 next a8 next null v 8 next a (8, 2, 5, 7) 58 Easy to remove a node if you have its predecessor! 59 a h a v 2 next a6 (2, 5, 8, 7) k a6 a6 v 5 next a2 a2 v 8 next a8 a8 v 7 next null Recursion h a (2, 5, 7) a a6 v 2 v 5 next a6 next a8 k a6 a2 v 8 next a8 a8 v 7 next null 59

11 6 Sum the digits in a non-negative integer /** return sum of digits in n. * Precondition: n >= */ pulic static int sum(int n) { if (n < ) return n; // { n has at least two digits // return first digit + sum of rest return sum(n/) + n% ; E.g. sum(7) = 7 E.g. sum(873) = sum(87) + 3; sum calls itself! 62 Stack Frame A frame contains information aout a method call: At runtime, Java maintains a stack that contains frames for all method calls that are eing executed ut have not completed. local variales parameters return info Method call: push a frame for call on stack, assign argument values to parameters, execute method ody. Use the frame for the call to reference local variales, parameters. End of method call: pop its frame from the stack; if it is a function, leave the return value on top of stack.

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

CS/ENGRD 2110 FALL Lecture 7: Interfaces and Abstract Classes 1 CS/ENGRD 2110 FALL 2016 Lecture 7: Interfaces and Abstract Classes http://courses.cs.cornell.edu/cs2110 Announcements 2 Attendance for this week s recitation is mandatory! A2 is due Today Get started

More information

Recitation 3. 2D Arrays, Exceptions

Recitation 3. 2D Arrays, Exceptions Recitation 3 2D Arrays, Exceptions 2D arrays 2D Arrays Many applications have multidimensional structures: Matrix operations Collection of lists Board games (Chess, Checkers) Images (rows and columns of

More information

Prelim 1. Solution. CS 2110, 14 March 2017, 7:30 PM Total Question Name Short answer

Prelim 1. Solution. CS 2110, 14 March 2017, 7:30 PM Total Question Name Short answer Prelim 1. Solution CS 2110, 14 March 2017, 7:30 PM 1 2 3 4 5 Total Question Name Short answer OO Recursion Loop invariants Max 1 36 33 15 15 100 Score Grader 1. Name (1 point) Write your name and NetID

More information

Prelim 1. Solution. CS 2110, 14 March 2017, 5:30 PM Total Question Name Short answer

Prelim 1. Solution. CS 2110, 14 March 2017, 5:30 PM Total Question Name Short answer Prelim 1. Solution CS 2110, 14 March 2017, 5:30 PM 1 2 3 4 5 Total Question Name Short answer OO Recursion Loop invariants Max 1 36 33 15 15 100 Score Grader 1. Name (1 point) Write your name and NetID

More information

Prelim 1. CS 2110, 14 March 2017, 5:30 PM Total Question Name Short answer. OO Recursion Loop invariants Max Score Grader

Prelim 1. CS 2110, 14 March 2017, 5:30 PM Total Question Name Short answer. OO Recursion Loop invariants Max Score Grader Prelim 1 CS 2110, 14 March 2017, 5:30 PM 1 2 3 4 5 Total Question Name Short answer OO Recursion Loop invariants Max 1 36 33 15 15 100 Score Grader The exam is closed ook and closed notes. Do not egin

More information

Prelim 1. CS 2110, 14 March 2017, 7:30 PM Total Question Name Short answer. OO Recursion Loop invariants Max Score Grader

Prelim 1. CS 2110, 14 March 2017, 7:30 PM Total Question Name Short answer. OO Recursion Loop invariants Max Score Grader Prelim 1 CS 2110, 14 March 2017, 7:30 PM 1 2 3 4 5 Total Question Name Short answer OO Recursion Loop invariants Max 1 36 33 15 15 100 Score Grader The exam is closed ook and closed notes. Do not egin

More information

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

CS/ENGRD 2110 SPRING Lecture 7: Interfaces and Abstract Classes CS/ENGRD 2110 SPRING 2019 Lecture 7: Interfaces and Abstract Classes http://courses.cs.cornell.edu/cs2110 1 Announcements 2 A2 is due Thursday night (14 February) Go back to Lecture 6 & discuss method

More information

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

CS/ENGRD 2110 FALL Lecture 7: Interfaces and Abstract Classes CS/ENGRD 2110 FALL 2017 Lecture 7: Interfaces and Abstract Classes http://courses.cs.cornell.edu/cs2110 1 Announcements 2 A2 is due tomorrow night (17 February) Get started on A3 a method every other day.

More information

CS/ENGRD 2110 SPRING 2018

CS/ENGRD 2110 SPRING 2018 CS/ENGRD 2110 SPRING 2018 Lecture 7: Interfaces and http://courses.cs.cornell.edu/cs2110 1 2 St Valentine s Day! It's Valentines Day, and so fine! Good wishes to you I consign.* But since you're my students,

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

SEARCHING, SORTING, AND ASYMPTOTIC COMPLEXITY

SEARCHING, SORTING, AND ASYMPTOTIC COMPLEXITY 1 A3 and Prelim 2 SEARCHING, SORTING, AND ASYMPTOTIC COMPLEXITY Lecture 11 CS2110 Fall 2016 Deadline for A3: tonight. Only two late days allowed (Wed-Thur) Prelim: Thursday evening. 74 conflicts! If you

More information

Prelim 1 Solutions. CS 2110, March 10, 2015, 5:30 PM Total Question True False. Loop Invariants Max Score Grader

Prelim 1 Solutions. CS 2110, March 10, 2015, 5:30 PM Total Question True False. Loop Invariants Max Score Grader Prelim 1 Solutions CS 2110, March 10, 2015, 5:30 PM 1 2 3 4 5 Total Question True False Short Answer Recursion Object Oriented Loop Invariants Max 20 15 20 25 20 100 Score Grader The exam is closed book

More information

CORRECTNESS ISSUES AND LOOP INVARIANTS

CORRECTNESS ISSUES AND LOOP INVARIANTS Aout A2 and feedack. Recursion 2 CORRECTNESS ISSUES AND LOOP INVARIANTS S2 has een graded. If you got 30/30, you will proaly have no feedack. If you got less than full credit, there should e feedack showing

More information

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this

More information

Index. Strong versus weak typing. Type: Set of values together with operations on them. Casting among types

Index. Strong versus weak typing. Type: Set of values together with operations on them. Casting among types CS Fall 3. David Gries These slides lead you simply through OO Java, rarely use unexplained terms. Examples, rather than formal definitions, are the norm. Pages..3 are an index into the slides, helping

More information

Prelim 1 SOLUTION. CS 2110, September 29, 2016, 7:30 PM Total Question Name Loop invariants. Recursion OO Short answer

Prelim 1 SOLUTION. CS 2110, September 29, 2016, 7:30 PM Total Question Name Loop invariants. Recursion OO Short answer Prelim 1 SOLUTION CS 2110, September 29, 2016, 7:30 PM 0 1 2 3 4 5 Total Question Name Loop invariants Recursion OO Short answer Exception handling Max 1 15 15 25 34 10 100 Score Grader 0. Name (1 point)

More information

About this exam review

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

Prelim 1. CS 2110, October 1, 2015, 5:30 PM Total Question Name True Short Testing Strings Recursion

Prelim 1. CS 2110, October 1, 2015, 5:30 PM Total Question Name True Short Testing Strings Recursion Prelim 1 CS 2110, October 1, 2015, 5:30 PM 0 1 2 3 4 5 Total Question Name True Short Testing Strings Recursion False Answer Max 1 20 36 16 15 12 100 Score Grader The exam is closed book and closed notes.

More information

Prelim 1. CS2110, October 2, 2014, 5:30 PM Extra Total Question TrueFalse Multiple Object Oriented

Prelim 1. CS2110, October 2, 2014, 5:30 PM Extra Total Question TrueFalse Multiple Object Oriented Prelim 1 CS2110, October 2, 2014, 5:30 PM 1 2 3 4 5 Extra Total Question TrueFalse Multiple Object Oriented Recursion Lists Extra Credit Max 20 20 30 15 15 5 100 Score Grader The exam is closed book and

More information

CSC Java Programming, Fall Java Data Types and Control Constructs

CSC Java Programming, Fall Java Data Types and Control Constructs CSC 243 - Java Programming, Fall 2016 Java Data Types and Control Constructs Java Types In general, a type is collection of possible values Main categories of Java types: Primitive/built-in Object/Reference

More information

Java Primer. CITS2200 Data Structures and Algorithms. Topic 2

Java Primer. CITS2200 Data Structures and Algorithms. Topic 2 CITS2200 Data Structures and Algorithms Topic 2 Java Primer Review of Java basics Primitive vs Reference Types Classes and Objects Class Hierarchies Interfaces Exceptions Reading: Lambert and Osborne,

More information

Types, Values and Variables (Chapter 4, JLS)

Types, Values and Variables (Chapter 4, JLS) Lecture Notes CS 141 Winter 2005 Craig A. Rich Types, Values and Variables (Chapter 4, JLS) Primitive Types Values Representation boolean {false, true} 1-bit (possibly padded to 1 byte) Numeric Types Integral

More information

1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4. Epic Test Review 5 Epic Test Review 6 Epic Test Review 7 Epic Test Review 8

1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4. Epic Test Review 5 Epic Test Review 6 Epic Test Review 7 Epic Test Review 8 Epic Test Review 1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4 Write a line of code that outputs the phase Hello World to the console without creating a new line character. System.out.print(

More information

Prelim 1, Solution. CS 2110, 13 March 2018, 7:30 PM Total Question Name Short answer

Prelim 1, Solution. CS 2110, 13 March 2018, 7:30 PM Total Question Name Short answer Prelim 1, Solution CS 2110, 13 March 2018, 7:30 PM 1 2 3 4 5 6 Total Question Name Short answer Exception handling Recursion OO Loop invariants Max 1 30 11 14 30 14 100 Score Grader The exam is closed

More information

Casting. References. References

Casting. References. References Casting February 2, 2018 1 References Let A be a class and B be a subclass of A. A reference variable of type A may refer to an object of type either A or B. A reference variable of type B may refer to

More information

Language Features. 1. The primitive types int, double, and boolean are part of the AP

Language Features. 1. The primitive types int, double, and boolean are part of the AP Language Features 1. The primitive types int, double, and boolean are part of the AP short, long, byte, char, and float are not in the subset. In particular, students need not be aware that strings are

More information

Index COPYRIGHTED MATERIAL

Index COPYRIGHTED MATERIAL Index COPYRIGHTED MATERIAL Note to the Reader: Throughout this index boldfaced page numbers indicate primary discussions of a topic. Italicized page numbers indicate illustrations. A abstract classes

More information

CS 1110 Final, December 9th, Question Points Score Total: 100

CS 1110 Final, December 9th, Question Points Score Total: 100 CS 1110 Final, Decemer 9th, 2015 This 150-minute exam has 8 questions worth a total of 100 points. Scan the whole test efore starting. Budget your time wisely. Use the ack of the pages if you need more

More information

Prelim 2 Solution. CS 2110, November 19, 2015, 7:30 PM Total. Sorting Invariants Max Score Grader

Prelim 2 Solution. CS 2110, November 19, 2015, 7:30 PM Total. Sorting Invariants Max Score Grader Prelim 2 CS 2110, November 19, 2015, 7:30 PM 1 2 3 4 5 6 Total Question True Short Complexity Searching Trees Graphs False Answer Sorting Invariants Max 20 15 13 14 17 21 100 Score Grader The exam is closed

More information

ITI Introduction to Computing II

ITI Introduction to Computing II ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Interface Abstract data types Version of January 26, 2013 Abstract These lecture notes are meant

More information

Prelim 1. CS 2110, September 29, 2016, 7:30 PM Total Question Name Loop invariants

Prelim 1. CS 2110, September 29, 2016, 7:30 PM Total Question Name Loop invariants Prelim 1 CS 2110, September 29, 2016, 7:30 PM 0 1 2 3 4 5 Total Question Name Loop invariants Recursion OO Short answer Exception handling Max 1 15 15 25 34 10 100 Score Grader The exam is closed book

More information

C a; C b; C e; int c;

C a; C b; C e; int c; CS1130 section 3, Spring 2012: About the Test 1 Purpose of test The purpose of this test is to check your knowledge of OO as implemented in Java. There is nothing innovative, no deep problem solving, no

More information

ITI Introduction to Computing II

ITI Introduction to Computing II ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance Introduction Generalization/specialization Version of January 20, 2014 Abstract

More information

Operators and Expressions

Operators and Expressions Operators and Expressions Conversions. Widening and Narrowing Primitive Conversions Widening and Narrowing Reference Conversions Conversions up the type hierarchy are called widening reference conversions

More information

ASYMPTOTIC COMPLEXITY

ASYMPTOTIC COMPLEXITY Simplicity is a great virtue but it requires hard work to achieve it and education to appreciate it. And to make matters worse: complexity sells better. - Edsger Dijkstra ASYMPTOTIC COMPLEXITY Lecture

More information

ITI Introduction to Computing II

ITI Introduction to Computing II ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance Introduction Generalization/specialization Version of January 21, 2013 Abstract

More information

Outline. Parts 1 to 3 introduce and sketch out the ideas of OOP. Part 5 deals with these ideas in closer detail.

Outline. Parts 1 to 3 introduce and sketch out the ideas of OOP. Part 5 deals with these ideas in closer detail. OOP in Java 1 Outline 1. Getting started, primitive data types and control structures 2. Classes and objects 3. Extending classes 4. Using some standard packages 5. OOP revisited Parts 1 to 3 introduce

More information

CS 1110: Introduction to Computing Using Python Loop Invariants

CS 1110: Introduction to Computing Using Python Loop Invariants CS 1110: Introduction to Computing Using Python Lecture 21 Loop Invariants [Andersen, Gries, Lee, Marschner, Van Loan, White] Announcements Prelim 2 conflicts due by midnight tonight Lab 11 is out Due

More information

Full file at Chapter 2 - Inheritance and Exception Handling

Full file at   Chapter 2 - Inheritance and Exception Handling Chapter 2 - Inheritance and Exception Handling TRUE/FALSE 1. The superclass inherits all its properties from the subclass. ANS: F PTS: 1 REF: 76 2. Private members of a superclass can be accessed by a

More information

Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach.

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

Fall 2017 CISC124 9/16/2017

Fall 2017 CISC124 9/16/2017 CISC124 Labs start this week in JEFF 155: Meet your TA. Check out the course web site, if you have not already done so. Watch lecture videos if you need to review anything we have already done. Problems

More information

Pace University. Fundamental Concepts of CS121 1

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

Values and Variables 1 / 30

Values and Variables 1 / 30 Values and Variables 1 / 30 Values 2 / 30 Computing Computing is any purposeful activity that marries the representation of some dynamic domain with the representation of some dynamic machine that provides

More information

Topics Introduction to Microprocessors

Topics Introduction to Microprocessors Topics 22440 Introduction to Microprocessors C-Language Review (I) Important: : You will not learn how to code in C in this one lecture! You ll still need some sort of C reference. C Syntax Important Tidits

More information

Exam 1 Prep. Dr. Demetrios Glinos University of Central Florida. COP3330 Object Oriented Programming

Exam 1 Prep. Dr. Demetrios Glinos University of Central Florida. COP3330 Object Oriented Programming Exam 1 Prep Dr. Demetrios Glinos University of Central Florida COP3330 Object Oriented Programming Progress Exam 1 is a Timed Webcourses Quiz You can find it from the "Assignments" link on Webcourses choose

More information

A Third Look At Java. Chapter Seventeen Modern Programming Languages, 2nd ed. 1

A Third Look At Java. Chapter Seventeen Modern Programming Languages, 2nd ed. 1 A Third Look At Java Chapter Seventeen Modern Programming Languages, 2nd ed. 1 A Little Demo public class Test { public static void main(string[] args) { int i = Integer.parseInt(args[0]); int j = Integer.parseInt(args[1]);

More information

Program Fundamentals

Program Fundamentals Program Fundamentals /* HelloWorld.java * The classic Hello, world! program */ class HelloWorld { public static void main (String[ ] args) { System.out.println( Hello, world! ); } } /* HelloWorld.java

More information

Prelim 2. CS 2110, November 19, 2015, 7:30 PM Total. Sorting Invariants Max Score Grader

Prelim 2. CS 2110, November 19, 2015, 7:30 PM Total. Sorting Invariants Max Score Grader Prelim 2 CS 2110, November 19, 2015, 7:30 PM 1 2 3 4 5 6 Total Question True Short Complexity Searching Trees Graphs False Answer Sorting Invariants Max 20 15 13 14 17 21 100 Score Grader The exam is closed

More information

Use the scantron sheet to enter the answer to questions (pages 1-6)

Use the scantron sheet to enter the answer to questions (pages 1-6) Use the scantron sheet to enter the answer to questions 1-100 (pages 1-6) Part I. Mark A for True, B for false. (1 point each) 1. Abstraction allow us to specify an object regardless of how the object

More information

5/23/2015. Core Java Syllabus. VikRam ShaRma

5/23/2015. Core Java Syllabus. VikRam ShaRma 5/23/2015 Core Java Syllabus VikRam ShaRma Basic Concepts of Core Java 1 Introduction to Java 1.1 Need of java i.e. History 1.2 What is java? 1.3 Java Buzzwords 1.4 JDK JRE JVM JIT - Java Compiler 1.5

More information

CSE 143 Lecture 20. Circle

CSE 143 Lecture 20. Circle CSE 143 Lecture 20 Abstract classes Circle public class Circle { private double radius; public Circle(double radius) { this.radius = radius; public double area() { return Math.PI * radius * radius; public

More information

ASYMPTOTIC COMPLEXITY

ASYMPTOTIC COMPLEXITY Simplicity is a great virtue but it requires hard work to achieve it and education to appreciate it. And to make matters worse: complexity sells better. - Edsger Dijkstra ASYMPTOTIC COMPLEXITY Lecture

More information

RECURSION (CONTINUED)

RECURSION (CONTINUED) RECURSION (CONTINUED) Lecture 9 CS2110 Fall 2017 Prelim one week from Thursday 1. Visit Exams page of course website, check what time your prelim is, complete assignment P1Conflict ONLY if necessary. So

More information

Prelim 1. CS 2110, 13 March 2018, 7:30 PM Total Question Name Short answer

Prelim 1. CS 2110, 13 March 2018, 7:30 PM Total Question Name Short answer Prelim 1 CS 2110, 13 March 2018, 7:30 PM 1 2 3 4 5 6 Total Question Name Short answer Exception handling Recursion OO Loop invariants Max 1 30 11 14 30 14 100 Score Grader The exam is closed book and closed

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

The Sun s Java Certification and its Possible Role in the Joint Teaching Material

The Sun s Java Certification and its Possible Role in the Joint Teaching Material The Sun s Java Certification and its Possible Role in the Joint Teaching Material Nataša Ibrajter Faculty of Science Department of Mathematics and Informatics Novi Sad 1 Contents Kinds of Sun Certified

More information

CS101 Part 2: Practice Questions Algorithms on Arrays, Classes and Objects, String Class, Stack Class

CS101 Part 2: Practice Questions Algorithms on Arrays, Classes and Objects, String Class, Stack Class CS1 Part 2: Algorithms on Arrays, Classes and Objects, String Class, Stack Class 1. Write a method that, given two sorted arrays of integers, merges the two arrays into a single sorted array that is returned.

More information

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018 Object-oriented programming 1 and data-structures CS/ENGRD 2110 SUMMER 2018 Lecture 4: OO Principles - Polymorphism http://courses.cs.cornell.edu/cs2110/2018su Lecture 3 Recap 2 Good design principles.

More information

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

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

CS 177 Week 15 Recitation Slides. Review

CS 177 Week 15 Recitation Slides. Review CS 177 Week 15 Recitation Slides Review 1 Announcements Final Exam on Friday Dec. 18 th STEW 183 from 1 3 PM Complete your online review of your classes. Your opinion matters!!! Project 6 due Just kidding

More information

1 Shyam sir JAVA Notes

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

Basic Techniques. Recursion. Today: Later on: Recursive methods who call themselves directly or indirectly.

Basic Techniques. Recursion. Today: Later on: Recursive methods who call themselves directly or indirectly. La 2 Recursion Basic Techniques SMD135 Programs and Data Structures Lecture 7 Sorting: Divide-and- Conquer Brute force Selection sort Insertion sort Linear proing [seaching through an unordered array]

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

Declarations and Access Control SCJP tips

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

Objects and Iterators

Objects and Iterators Objects and Iterators Can We Have Data Structures With Generic Types? What s in a Bag? All our implementations of collections so far allowed for one data type for the entire collection To accommodate a

More information

Points To Remember for SCJP

Points To Remember for SCJP Points To Remember for SCJP www.techfaq360.com The datatype in a switch statement must be convertible to int, i.e., only byte, short, char and int can be used in a switch statement, and the range of the

More information

Semantic Analysis. CSE 307 Principles of Programming Languages Stony Brook University

Semantic Analysis. CSE 307 Principles of Programming Languages Stony Brook University Semantic Analysis CSE 307 Principles of Programming Languages Stony Brook University http://www.cs.stonybrook.edu/~cse307 1 Role of Semantic Analysis Syntax vs. Semantics: syntax concerns the form of a

More information

Argument Passing All primitive data types (int etc.) are passed by value and all reference types (arrays, strings, objects) are used through refs.

Argument Passing All primitive data types (int etc.) are passed by value and all reference types (arrays, strings, objects) are used through refs. Local Variable Initialization Unlike instance vars, local vars must be initialized before they can be used. Eg. void mymethod() { int foo = 42; int bar; bar = bar + 1; //compile error bar = 99; bar = bar

More information

Outline. Java Models for variables Types and type checking, type safety Interpretation vs. compilation. Reasoning about code. CSCI 2600 Spring

Outline. Java Models for variables Types and type checking, type safety Interpretation vs. compilation. Reasoning about code. CSCI 2600 Spring Java Outline Java Models for variables Types and type checking, type safety Interpretation vs. compilation Reasoning about code CSCI 2600 Spring 2017 2 Java Java is a successor to a number of languages,

More information

Final exam. CS 2110, December 15, 2016, 9:00AM

Final exam. CS 2110, December 15, 2016, 9:00AM Final exam CS 2110, December 15, 2016, 9:00AM Question Short Trie Loop Exp Rec Gen Span Mon BigO Data Total Max 20 7 9 10 9 9 8 10 10 8 100 Score Grader The exam is closed book and closed notes. Do not

More information

Overview. ITI Introduction to Computing II. Interface 1. Problem 1. Problem 1: Array sorting. Problem 1: Array sorting. Problem 1: Array sorting

Overview. ITI Introduction to Computing II. Interface 1. Problem 1. Problem 1: Array sorting. Problem 1: Array sorting. Problem 1: Array sorting Overview ITI 1121. Introduction to Computing II Rafael Falcon and Marcel Turcotte (with contributions from R. Holte) Electrical Engineering and Computer Science University of Ottawa Interface Abstract

More information

Prelim 1. CS 2110, March 15, 2016, 5:30 PM Total Question Name True False. Short Answer

Prelim 1. CS 2110, March 15, 2016, 5:30 PM Total Question Name True False. Short Answer Prelim 1 CS 2110, March 15, 2016, 5:30 PM 0 1 2 3 4 5 Total Question Name True False Short Answer Object- Oriented Recursion Loop Invariants Max 1 20 14 25 19 21 100 Score Grader The exam is closed book

More information

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

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

Prelim 2 Solution. CS 2110, November 19, 2015, 5:30 PM Total. Sorting Invariants Max Score Grader

Prelim 2 Solution. CS 2110, November 19, 2015, 5:30 PM Total. Sorting Invariants Max Score Grader Prelim 2 CS 2110, November 19, 2015, 5:30 PM 1 2 3 4 5 6 Total Question True Short Complexity Searching Trees Graphs False Answer Sorting Invariants Max 20 15 13 14 17 21 100 Score Grader The exam is closed

More information

Getting started with Java

Getting started with Java Getting started with Java Magic Lines public class MagicLines { public static void main(string[] args) { } } Comments Comments are lines in your code that get ignored during execution. Good for leaving

More information

SORTING 9/26/18. Prelim 1. Prelim 1. Why Sorting? InsertionSort. Some Sorting Algorithms. Tonight!!!! Two Sessions:

SORTING 9/26/18. Prelim 1. Prelim 1. Why Sorting? InsertionSort. Some Sorting Algorithms. Tonight!!!! Two Sessions: Prelim 1 2 "Organizing is wat you do efore you do someting, so tat wen you do it, it is not all mixed up." ~ A. A. Milne SORTING Tonigt!!!! Two Sessions: You sould now y now wat room to tae te final. Jenna

More information

Programming with Java

Programming with Java Programming with Java Data Types & Input Statement Lecture 04 First stage Software Engineering Dep. Saman M. Omer 2017-2018 Objectives q By the end of this lecture you should be able to : ü Know rules

More information

Race Conditions & Synchronization

Race Conditions & Synchronization Gries office hours 2 A numer of students have asked for time to talk over how to study for the prelim. Gries will hold office hours at the times elow for this purpose. Also, read asiclearningmethods.pdf

More information

Introduction to Linked Lists. Introduction to Recursion Search Algorithms CS 311 Data Structures and Algorithms

Introduction to Linked Lists. Introduction to Recursion Search Algorithms CS 311 Data Structures and Algorithms Introduction to Linked Lists Introduction to Recursion Search Algorithms CS 311 Data Structures and Algorithms Lecture Slides Friday, September 25, 2009 Glenn G. Chappell Department of Computer Science

More information

CS 162, Lecture 25: Exam II Review. 30 May 2018

CS 162, Lecture 25: Exam II Review. 30 May 2018 CS 162, Lecture 25: Exam II Review 30 May 2018 True or False Pointers to a base class may be assigned the address of a derived class object. In C++ polymorphism is very difficult to achieve unless you

More information

Prelim 1. CS 2110, 13 March 2018, 5:30 PM Total Question Name Short answer

Prelim 1. CS 2110, 13 March 2018, 5:30 PM Total Question Name Short answer Prelim 1 CS 2110, 13 March 2018, 5:30 PM 1 2 3 4 5 6 Total Question Name Short answer Exception handling Recursion OO Loop invariants Max 1 30 11 14 30 14 100 Score Grader The exam is closed book and closed

More information

1B1b Inheritance. Inheritance. Agenda. Subclass and Superclass. Superclass. Generalisation & Specialisation. Shapes and Squares. 1B1b Lecture Slides

1B1b Inheritance. Inheritance. Agenda. Subclass and Superclass. Superclass. Generalisation & Specialisation. Shapes and Squares. 1B1b Lecture Slides 1B1b Inheritance Agenda Introduction to inheritance. How Java supports inheritance. Inheritance is a key feature of object-oriented oriented programming. 1 2 Inheritance Models the kind-of or specialisation-of

More information

Announcements SORTING. Prelim 1. Announcements. A3 Comments 9/26/17. This semester s event is on Saturday, November 4 Apply to be a teacher!

Announcements SORTING. Prelim 1. Announcements. A3 Comments 9/26/17. This semester s event is on Saturday, November 4 Apply to be a teacher! Announcements 2 "Organizing is wat you do efore you do someting, so tat wen you do it, it is not all mixed up." ~ A. A. Milne SORTING Lecture 11 CS2110 Fall 2017 is a program wit a teac anyting, learn

More information

Announcements/Follow-ups

Announcements/Follow-ups Announcements/Follow-ups Midterm #2 Friday Everything up to and including today Review section tomorrow Study set # 6 online answers posted later today P5 due next Tuesday A good way to study Style omit

More information

Building Java Programs

Building Java Programs Building Java Programs A Back to Basics Approach Stuart Reges I Marty Stepp University ofwashington Preface 3 Chapter 1 Introduction to Java Programming 25 1.1 Basic Computing Concepts 26 Why Programming?

More information

XC Total Max Score Grader

XC Total Max Score Grader NAME: NETID: CS2110 Fall 2013, Prelim 1 Thursday Oct 10, 2013 (7:30-9:00p) The exam is closed book and closed notes. Do not begin until instructed. You have 90 minutes. Good luck! Write your name and Cornell

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

CS1622. Semantic Analysis. The Compiler So Far. Lecture 15 Semantic Analysis. How to build symbol tables How to use them to find

CS1622. Semantic Analysis. The Compiler So Far. Lecture 15 Semantic Analysis. How to build symbol tables How to use them to find CS1622 Lecture 15 Semantic Analysis CS 1622 Lecture 15 1 Semantic Analysis How to build symbol tables How to use them to find multiply-declared and undeclared variables. How to perform type checking CS

More information

Java Primer 1: Types, Classes and Operators

Java Primer 1: Types, Classes and Operators Java Primer 1 3/18/14 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser, Wiley, 2014 Java Primer 1: Types,

More information

Computer Science 1 Ah

Computer Science 1 Ah UNIVERSITY OF EDINBURGH course CS0077 COLLEGE OF SCIENCE AND ENGINEERING SCHOOL OF INFORMATICS Computer Science 1 Ah Resit Examination Specimen Solutions Date: Monday 1st September 2003 Time: 09:30 11:00

More information

"Organizing is what you do before you do something, so that when you do it, it is not all mixed up." ~ A. A. Milne SORTING

Organizing is what you do before you do something, so that when you do it, it is not all mixed up. ~ A. A. Milne SORTING "Organizing is what you do before you do something, so that when you do it, it is not all mixed up." ~ A. A. Milne SORTING Lecture 11 CS2110 Fall 2017 Prelim 1 2 It's on Tuesday Evening (3/13) Two Sessions:

More information

Two Types of Types. Primitive Types in Java. Using Primitive Variables. Class #07: Java Primitives. Integer types.

Two Types of Types. Primitive Types in Java. Using Primitive Variables. Class #07: Java Primitives. Integer types. Class #07: Java Primitives Software Design I (CS 120): M. Allen, 13 Sep. 2018 Two Types of Types So far, we have mainly been dealing with objects, like DrawingGizmo, Window, Triangle, that are: 1. Specified

More information

SORTING. Insertion sort Selection sort Quicksort Mergesort And their asymptotic time complexity

SORTING. Insertion sort Selection sort Quicksort Mergesort And their asymptotic time complexity 1 SORTING Insertion sort Selection sort Quicksort Mergesort And their asymptotic time complexity See lecture notes page, row in table for this lecture, for file searchsortalgorithms.zip Lecture 11 CS2110

More information

Inheritance Motivation

Inheritance Motivation Inheritance Inheritance Motivation Inheritance in Java is achieved through extending classes Inheritance enables: Code re-use Grouping similar code Flexibility to customize Inheritance Concepts Many real-life

More information

Java Object Oriented Design. CSC207 Fall 2014

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

CSC System Development with Java. Exception Handling. Department of Statistics and Computer Science. Budditha Hettige

CSC System Development with Java. Exception Handling. Department of Statistics and Computer Science. Budditha Hettige CSC 308 2.0 System Development with Java Exception Handling Department of Statistics and Computer Science 1 2 Errors Errors can be categorized as several ways; Syntax Errors Logical Errors Runtime Errors

More information

Modern Programming Languages. Lecture Java Programming Language. An Introduction

Modern Programming Languages. Lecture Java Programming Language. An Introduction Modern Programming Languages Lecture 27-30 Java Programming Language An Introduction 107 Java was developed at Sun in the early 1990s and is based on C++. It looks very similar to C++ but it is significantly

More information

ITI Introduction to Computing II

ITI Introduction to Computing II ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance (part II) Polymorphism Version of January 21, 2013 Abstract These lecture notes

More information

Final Exam Practice Questions

Final Exam Practice Questions Final Exam Practice Questions 1. Short Answer Questions (10 points total) (a) Given the following hierarchy: class Alpha {... class Beta extends Alpha {... class Gamma extends Beta {... What order are

More information

Chapter 2: Using Data

Chapter 2: Using Data Chapter 2: Using Data TRUE/FALSE 1. A variable can hold more than one value at a time. F PTS: 1 REF: 52 2. The legal integer values are -2 31 through 2 31-1. These are the highest and lowest values that

More information