CMSI 3801
Exam 2 Preparation

When

Tuesday, November 11, 2025, last 45 minutes of class.

Scope

Functions, Functional Programming, Object Orientation, Modules, TypeScript, Haskell, Java, Kotlin, Swift. Do not fail to study languages from earlier units. You may see questions that focus on concepts such as types and functions, but applied to languages seen earlier in the course.

Ground Rules

In person, but you will be taking the exam on BrightSpace. Everyone takes the exam at the same time. As always, follow academic honesty procedures. There is to be no signaling answers. You have to work in a bubble.

Preparation Checklist

Do each of the following to maximize your preparation:

Were you able to check off every box?

An Outline of Course Content

The fact that active recall is better for acquiring long-term knowledge does not mean that outlines and concept maps are not useful. Learners should use multiple techniques—think “both and” rather than “either or.”

Functions
    Basic terminology
    Are parameters typed?
    Parameter association
    Named
    Positional
    Mixed
    Overloading
    Default parameters
    Rest parameters
    Function returns
    Argument passing
    Semantic
        in, out, in out
    Pragmatic
        By value
        By value-result
        By reference
        By name
        Aliasing
    Generic functions (for statically typed languages)
    Functions as values (higher order functions)
    Closures
    Comparison of closures to traditional objects
Functional Programming
    How it differs from other paradigms
    Big ideas
        Programming with side-effect-free functions
        Functions as first-class citizens
        Higher-order functions are common
        Recursion is used instead of loops
        Information hiding through closures
    Advantages
        Easier to reason about
        Easier to test
        Easier to parallelize (thread-safe)
        Easier to distribute (multi-core and multi-machine)
        Easier to optimize
        Easier to prove correct
    Basic ideas used in large-scale systems like MapReduce
    From imperative to functional
        Turn assignments into argument passing
        Turn loops into tail recursion
        Turn mutable data into immutable (persistent) data
    Some higher order functions
        map, filter, reduce, flatMap
        every, some, find, reject
        takeWhile, dropWhile
Classes and Objects
    What a class is and is not
        It is not a type, but is associated with one
        It is a factory for creating objects
        (It is also a run-time type tag)
    Instances
    Properties and Operations
    Fields and Methods and Constructors
    Static members vs instance members
    Kinds of classes
        Enumeration
        Singleton
        Abstract
        Sealed
        Final
        Open
    Passive vs Active things
    Things that probably should not be classes but are in Java
        Utility classes
        Application classes
    Example classes in several languages
    Enforcing Immutability
    Managing the mixing of references and mutability
        Disallowing copying
        Defensive copying
    Information Hiding
    Multiple Inheritance
        Reasons it is messy
    Enums as an alternative to inheritance
    Class design tips
        Handle failure at every method
        Hide representation
        Keep interfaces minimal
        Consider Immutability
        Favor factory methods over constructors
Object Orientation
    The Object-oriented view vs the Process-oriented view
        PO: processes operating on objects
        OO: objects that have behaviors
    Organizing code in the two views:
        PO: top-level functions that operate on data
        OO: objects that have functions as properties
    What the term OO originally meant
        Original principles:
            1. Everything is an object
            2. Objects send and receive messages
            3. Objects have their own memory
            4. Every object is an instance of a class
            5. Classes hold shared behavior
            6. Arguments are passed along in a message
        The BIG IDEA is messaging
        Kay's quote:
            "OOP to me means only messaging,
            local retention and protection and
            hiding of state-process, and extreme
            late-binding of all things."
        Bob Barton’s big idea about recursive decomposition
            The parts should look like the whole
    Classes vs Prototypes
        Classes: a blueprint for objects
        Prototypes: objects that are cloned
    Classes in various languages
    Procedural alternative to classes: enums
    Expression Problem
        Adding both operations and data without modifying existing code
        Implementation with extensions
    Why should we not have getters and setters
Modules
    Imports
    Exports
    Private to module vs. visible outside
Haskell
    1990
    Brings together three ideas:
        Lazy evaluation
        Static types
        Pure functions
    Binding, not assignment
    6 basic types
    Tuples
    data keyword to introduce new types
    Lists have two constructors, [] and :
    Type variables (always in lowercase)
    Typeclasses
    List ranges and comprehensions
    Infinite lists
    Strings are just lists
    Functions usually defined with pattern matching
    Guards for conditionals
    Maybe (for optionals)
    Either (for results)
    Data types
    Modules
    Monads
        Defined by return and >>= (bind)
        Good for chaining
        Examples: Maybe, List, IO
    Impure code isolated with IO monad
    What to read: Learn You a Haskell for Great Good
Java
    1995, Sun Microsystems, James Gosling
    Designed to be a better C++
    Extremely popular
    Enterprise language
    Evolves great over time
        New features added right!
    Java 25 is all we care about
    But still has a lot of unfixable problems
        Null in types (Optionals did not fully fix!)
        Overuse of classes
        Primitive types (confusing for an applications language)
        Native UTF-16
        Covariant arrays
    All programs organized as classes grouped into packages grouped into modules
    Primitive types have value semantics
        boolean, char, byte, short, int, long, float, double
    All other types have reference semantics
        Arrays, interfaces, classes, enums, records
    Not too much type inference (pretty much just var for local variables)
    Has a REPL called jshell
    Variables have (static) types, objects have (dynamic) classes
    Generics limited to reference types (ugh)
    Billion Dollar Mistake present in a very nasty way
        ALL reference types have null statically but not dynamically
    Has optionals but their use is not required!
    Streams are nice
        Sources
            arrays, collections, generation functions, files, ...
        Intermediate Operations
            filter, map, flatMap, distinct, sorted, peek, limit, skip, ...
        Terminal Operations
            forEach, forEachOrdered, toArray, reduce, collect, min, max, count, anyMatch, allMatch, findFirst, findAny...
    Lambdas
    Nice concurrency features
    Absolutely massive standard library
Kotlin
    2011, JetBrains
    Interoperable with Java
    Designed to fix a lot of Java’s problems
    Many elegant, useful, and safe features
        Null safety
        Data classes
        Extension functions
        Smart casts
        Coroutines
        Sealed classes
        Type inference
        Operator overloading
        Companion objects
        Destructuring declarations
        Lambdas (and the cool it keyword)
        Inline functions
        Reified type parameters
        Type aliases
        Late-initialized properties
        Great concurrency features
Swift
    2014, Apple, Chris Lattner
    Designed to replace Objective-C on iOS, macOS, etc.
    Elegant, expressive, and safe
    Praised for its safety features
    Known for protocol-oriented programming
    Feels like a scripting language, performs like a systems language
    Static types everywhere
        But with extensive type inference
    All types are Structs, Classes, Enums, Tuples, Functions, Prototypes
    Lots of number types (Int8, UInt8, Int16, UInt16, ..., Float, Double)
    Unicode correct, with proper understanding of normalization and graphemes
    Bool, Character, String, and the number types are actually structs!
    Structs and classes
        Structs have value semantics
            Properties, methods, initializers, subscripts
        Classes have reference semantics
            Struct features + inheritance, deinitializers, casting / dyn checking
        Properties can be stored or computed
    [T] for array of T, [K:V] for dictionary
    let for constants, var for mutable
        let-immutability is deep!
    Parameter names and argument labels
    Functions are special cases of closures
    Two syntaxes for closures: {x in x * 5} vs {$0 * 5}
    Enums are awesome
        Optionals have great syntax
            if-let, while-let, guard-else
            ?. ?[] ?() for option-chaining, and ?? (nil-coalescing operator)
         Recursive enums use indirect keyword
    Protocols
        Types *adopt* protocols
        Some useful ones: Equatable, Comparable, Hashable, Codable
    Extensions
    Closures have nice compact syntax
    Tuples
    Pattern matching
    Operator overloading
    Access control
    Memory management through ARC
        Need to understand weak references
    Errors as values (Result type),
        but you can throw and catch too (if errors are recoverable)
    Definitive Initialization
    Separate operators for modular arithmetic
    Concurrency
    Operator overloading AND you can create your own operators!

Format of the Exam

An ideal assessment of your understanding of programming language concepts would examine your fluency with the course material through an oral exam. However, given the the number of students, this assessment will be on your recognition and evaluation of concept expression in the form of multiple choice and similar questions.

You will have 45 minutes to complete the exam. Work quickly but carefully.

About the Problems

There will be 20 questions of the multiple choice, multiple select, fill-in-the-blank, and short answer variety.

Here are the general areas of coverage for each problem. Don’t read too much into these hints or you will end up getting confused. The hints are supposed to help you. If you don’t understand the hint, let it go—do not ask for clarification (since the hints were not required to be given in the first place).