THINK FIRST·CODE LATER

CPS 1231 · CPS 2231

Java Programming

Concept Reviews and Question Banks

Chapters
17
Questions
648
Labs
156
Your progress
0 · 0% correct

About this course

A two-course sequence that takes students from their very first program to well-designed object-oriented software in Java. Part I (CPS 1231) builds the foundations of programming and problem solving: how a computer runs a program, how to design an algorithm before writing it, and how to express it with variables, decisions, loops, methods and arrays. Part II (CPS 2231) turns those skills into object-oriented programming: classes and objects, encapsulation, inheritance, polymorphism, interfaces, exceptions, files and recursion.

This Learning Hub accompanies the course handbook: every chapter has a concept review, a question bank with explanations, and programming labs with model solutions.

Focus

Part I — Foundations (CPS 1231)

  • How computers, programs and the Java language work together
  • Algorithm design with pseudocode, flowcharts and hand tracing
  • Variables, data types, operators, expressions and type conversion
  • Characters, strings and console input
  • Selection, Boolean logic and loops
  • Methods and the Java API; one- and two-dimensional arrays

Part II — Object-Oriented Programming (CPS 2231)

  • Classes, objects, encapsulation, constructors and object references
  • Static members, utility classes and program design
  • ArrayList, StringBuilder and arrays of objects
  • Inheritance, composition, aggregation, polymorphism, abstract classes and interfaces
  • Exception handling, file input/output and recursion

Learning objectives

By the end of Part I (CPS 1231), students will be able to:

  1. Explain how a Java program is compiled and executed, and read and fix compiler and run-time errors.
  2. Design an algorithm with pseudocode or a flowchart and trace it by hand before coding it.
  3. Write correct programs using variables, expressions, strings, console input and output.
  4. Control program flow with selection statements, Boolean logic and loops.
  5. Decompose a problem into well-named methods and reuse the Java API library.
  6. Store and process collections of data with one- and two-dimensional arrays.

By the end of Part II (CPS 2231), students will be able to:

  1. Model a problem with classes and objects, and protect an object's state with encapsulation.
  2. Reason precisely about object references, constructors, overloading and static members.
  3. Use ArrayList, StringBuilder and arrays of objects to manage data.
  4. Design class hierarchies with inheritance and composition, and apply polymorphism, abstract classes and interfaces.
  5. Write robust programs that handle exceptions and read and write files.
  6. Solve problems recursively and explain how a recursive method executes.

Teaching approach

Think first, code later. Every topic starts from the problem and the algorithm — pseudocode, flowcharts, tracing tables — before the Java syntax. Students learn to predict what a program does, not only to type it.

  • Concept reviews explain each idea in plain language with short, complete examples and the classic mistakes to avoid.
  • Question banks train the skills programmers use every day: tracing code, predicting output, spotting code that does not compile, and explaining why. Every question has an explanation, available after the student has answered.
  • Programming labs ask for complete, working programs. Students write their solution in their own IDE, test it, and only then compare it with the model solution.
  • Progressive difficulty: each chapter moves from recognition to application to design, and Part II reuses and deepens everything from Part I.
  • Private, self-paced practice: students' answers and code stay in their own browser; progress is visible only to them.

Course content

Open a chapter to read its review, then practise with its question bank.

Foundations — CPS 1231

  1. Chapter 1 · Week 1

    Computers, Programs, and the Java Language

    hardware/software, source vs. bytecode, JVM, portability, identifiers

    0/40 answered
  2. Chapter 2 · Week 2

    Algorithm Design: Pseudocode, Flowcharts, and Tracing

    pseudocode, flowcharts, tracing, loop termination

    0/39 answered
  3. Chapter 3 · Week 3

    Java Basics: Class Structure, Variables, and Data Types

    class structure, variables, primitive types, constants

    0/38 answered
  4. Chapter 4 · Week 4

    Operators, Expressions, and Type Conversion

    precedence, integer division, casting, ++, ternary

    0/39 answered
  5. Chapter 5 · Week 5

    Characters, Strings, and Console Input

    char, escapes, references, String, Scanner

    0/38 answered
  6. Chapter 6 · Week 6

    Selection and Boolean Logic

    if, else if, &&, ||, !, switch

    0/38 answered
  7. Chapter 7 · Week 7

    Loops and Iteration

    while, do, for, nesting, input validation

    0/38 answered
  8. Chapter 8 · Week 9–11

    Methods and the Java API Library

    own methods, static, overloading, Math, printf

    0/40 answered
  9. Chapter 9 · Week 12–14

    Arrays and Two-Dimensional Arrays

    1-D and 2-D arrays, searching, sorting, case studies

    0/40 answered

Object-Oriented Programming — CPS 2231

  1. Chapter 10 · Week 1–3

    Classes, Objects, and Encapsulation

    instance variables, this, accessors, UML

    0/38 answered
  2. Chapter 11 · Week 4–5

    Object References, Constructors, and Overloading

    object creation, equality, chaining, constructors

    0/37 answered
  3. Chapter 12 · Week 6

    Class Members, Utility Classes, and Program Design

    static, utility classes, top-down design

    0/36 answered
  4. Chapter 13 · Week 7

    ArrayList, StringBuilder, and Arrays of Objects

    arrays of objects, collections, mutability

    0/37 answered
  5. Chapter 14 · Week 8–10

    Inheritance, Composition, and Aggregation

    hierarchies, super, overriding, final

    0/37 answered
  6. Chapter 15 · Week 11–12

    Polymorphism, Abstract Classes, and Interfaces

    dynamic binding, abstract, interface

    0/37 answered
  7. Chapter 16 · Week 13

    Exception Handling

    try/catch/finally, checked vs. unchecked

    0/38 answered
  8. Chapter 17 · Week 13–14

    File I/O and Recursion

    File, text I/O, base case, call stack

    0/38 answered

Exam review

Review games played in class before an exam. Each one comes with its answer key.

Labs

156 labs with model solutions

Realistic programming problems. Work out your own answer first, then compare.

Reference · Appendix B

Java Syntax and API Quick Reference

Keep it open while you work through the question banks.