Final Review - PowerPoint PPT Presentation

About This Presentation
Title:

Final Review

Description:

Look at the exercises in the text. finding errors in code. finding differences in code ... [ab][bc][cde]* abcde [A-C]DEF? ABCDE [truck].[stop] trstopstop. yes ... – PowerPoint PPT presentation

Number of Views:53
Avg rating:3.0/5.0
Slides: 45
Provided by: aseR1
Category:
Tags: final | review

less

Transcript and Presenter's Notes

Title: Final Review


1
Final Review
2
Final Details
  • Monday, December 11th
  • 700pm 1000pm
  • HCC 1325

3
Sections Covered - Detailed View
  • 1.1-1.2, 1.4-1.6
  • 2.1-2.6
  • 3.1-3.3, 3.6-3.8 covered 3.4, 3.5 in class
  • 4.1-4.4 covered 4.5 in class
  • 5.1-5.5, 5.7-5.8 (basically) covered 5.6 in
    class
  • 6.1-6.5, 6.7, 6.8 covered 6.9 in class
  • 7.1-7.2, 7.6-7.7 covered 7.4 in class
  • 8.1-8.5
  • 9.1-9.5
  • 10.1-10.6
  • 11.1-11.3
  • some parts of 12 covered in class notes

4
Sections Covered - Broadly
  • Chapters 1-11
  • (except for Graphics track)
  • with minor exceptions

5
Other Topics (from before midterm)
  • Running time / Big O notation
  • Working with references handout
  • including null/this
  • Merge sort
  • Command line arguments
  • printf

6
Other Topics (after midterm)
  • More detailed treatment of some topics
  • polymorphism (e.g. covered Collections)
  • file output (e.g. covered buffers and generic
    Writers)
  • File input
  • Call Stack
  • Scanning tokens
  • Regular Expressions

7
Chapter 1
  • Computer processing
  • The Java Programming Language
  • Program Development
  • Object-Oriented Programming
  • (very basic)

8
Chapter 2
  • Character Strings
  • Variables and Assignment
  • Primitive Data Types
  • Expressions
  • Data Conversion
  • Interactive Programs

9
Chapter 3
  • Creating Objects
  • The String Class
  • Packages
  • Formatting Output
  • (plus more detailed coverage of printf)
  • Enumerated Types
  • Wrapper Classes

10
Chapter 4
  • Anatomy of a Class
  • Encapsulation
  • Anatomy of a Method

11
Chapter 5
  • The if Statement and Conditions
  • Other Conditional Statements
  • Comparing Data
  • The while Statement
  • Other Repetition Statements

12
Chapter 6
  • Software Development Activities
  • Identifying Classes and Objects
  • Static Variables and Methods
  • Class Relationships
  • Interfaces
  • Method Design
  • Testing
  • (covered the same material in class)

13
Chapter 7
  • Declaring and Using Arrays
  • Two-Dimensional Arrays
  • The ArrayList Class

14
Chapter 8
  • Creating subclasses
  • Overriding methods
  • Class hierarchies
  • Inheritance and visibility
  • Designing for inheritance

15
Chapter 9
  • Polymorphism
  • polymorphic references
  • through inheritance
  • through interfaces
  • Searching
  • linear search
  • binary search
  • Sorting
  • insertion sort
  • selection sort
  • merge sort

16
Chapter 10
  • Exception Handling
  • The try-catch Statement
  • Exception Classes
  • I/O Exceptions

17
Chapter 11
  • Recursive Thinking
  • Recursive Programming
  • Using Recursion

18
Running Time Big-O
  • For a parameter n
  • e.g. the length of a string or size of an array
  • count the number of steps performed
  • loop through n elements n steps
  • loop inside a loop n2 steps
  • Ignore constants coefficients
  • 3n 2 steps O(n)
  • n2 /2 steps O(n2)
  • cutting problem in half at each step O(log n)

19
Working with References
  • null reference
  • Object variable not assigned anything
  • When does this cause an exception?
  • this reference
  • When does this simplify code?

20
File I/O
  • Where do the exceptions happen?
  • How do we handle them?
  • Why do we want to buffer?
  • How do we buffer?
  • Using Scanner
  • with default tokens
  • with defined tokens

21
Regular Expressions
  • Given regular expression
  • yes/no matching questions
  • give informal description
  • Given informal description
  • write regular expression
  • pass appropriately to Scanner

22
What Kind of Questions?
  • Look at the exercises in the text
  • finding errors in code
  • finding differences in code
  • explaining/defining concepts
  • predicting output of code
  • writing methods or classes
  • specifying/justifying design from requirements

23
What Kind of Questions?
  • Similar format for lecture material
  • e.g. specify running time
  • e.g. find null reference problem
  • Using regular expressions
  • Predicting tokens parsed
  • Describe call stack
  • including exceptions
  • explain stack trace

24
It May Be on the Test if
  • It is in the text
  • It is in the lecture notes
  • It is something I said in class or wrote on the
    blackboard
  • It was part of a lab/assignment

25
What Code Do You Need to Know?
  • Officially everything as per previous slide
  • Unofficially
  • I try to only assume you know important methods
    and classes
  • but I decide what is important
  • in general little used methods that occur rarely
    in the notes will be given implicitly
  • but you should know enough code to solve problems
    without help/look-up

26
Examples
  • There will be definitions (again)
  • abstract class
  • checked exception
  • final method
  • overridden method

27
Examples
  • There may be explanations required
  • Explain why a static method cannot refer to an
    instance variable.
  • Give two differences between an abstract class
    and an interface.

28
Examples
  • Draw a UML diagram for a single class hierarchy
    representing these animals, with abstract classes
    grouping animal types
  • parrot
  • gorilla
  • horse
  • bat
  • penguin
  • Add an interface for flyers

29
Examples
  • Correct the problems
  • Flyer polly new Parrot()
  • Animal koko new Gorilla()
  • Gorilla junior koko.makeOffspring()
  • polly.layEgg()

30
Examples
  • Define appropriate classes and public methods for
    the given requirements.
  • Every salesperson will be assigned a unique ID
    number, and a numbered office with a phone.
    Salespeople will sell vacuum cleaners at a fixed
    price. When inventory runs out, the top
    salesperson will be designated employee of the
    month.

31
Examples
  • Find the exception in this code, and handle it.
  • public static void main(String args)
  • FileWriter fileout new FileWriter(names.txt)
  • if(fileout!null)
  • fileout.write(John Smith)
  • else
  • System.out.println(No name written to file)

32
Examples
  • Find the exception in this code, and handle it.
  • public static void main(String args)
  • Student s new Student(4533453,tsmith)
  • String fname s.getFirstName()
  • System.out.println(fname)

33
Examples
  • Given this information in file.txt
  • 7 5 5p , 4
  • Write the code that will print these tokens to
    the screen using a Scanner/delimiter
  • 7 5 5 and , 4
  • 7 and and p , 4

34
Solution
  • Scanner filein new Scanner(
  • new File(file.txt)
  • ).useDelimiter(p)
  • while(filein.hasNext())
  • System.out.println(filein.next())

5
35
Examples
  • Yes or no expression matching
  • 1-7a? 43
  • (17)(17a)? 17a
  • abcdef(di)? bed
  • 123(45)?a 12312345aaaa
  • abbccde abcde
  • A-CDEF? ABCDE
  • truck.stop trstopstop

yes
no
no
yes
yes
no
yes
36
Examples
  • Describe the strings matching the expressions
  • (cat)
  • catcat
  • cat?
  • ca?t
  • (c?a)t?
  • c-ta?c-t

37
Examples
  • What is the value in variable temp after
  • int temp 30
  • String stemp temp 12
  • temp temp Integer.parseInt(stemp)
  • Again
  • CollectionltIntegergt l new ArrayListltInteg
    ergt
  • int temp 40
  • l.add(40)
  • temp l.size()

38
Examples
  • Write a method that picks a random character in
    the string string.

39
Examples
  • What is wrong with this?
  • How can it be corrected?
  • int count1,max0
  • while(countmax)
  • System.out.println(count)
  • count-2

40
Examples
  • A LinkedList implements Collection
  • Write a method that adds every word in the
    sentence This is a sentence to a LinkedList,
    then prints the size.

41
Examples
  • Given double input, write a method that returns
    the highest value

42
Examples
  • Write a class NamedArrayList that extends
    ArrayList by adding a name for the array list in
    the first position.

43
Examples
  • What is wrong with these declarations
  • char chars d, a, b
  • String new String5
  • Scanner sc new Scanner(5)

44
Examples
  • Write a recursive function that returns true if
    the input is a power of 3.
  • Write a recursive function that returns true if a
    string contains only the letter s.
Write a Comment
User Comments (0)
About PowerShow.com