CPSC 124 Introduction to Programming Spring 2024

Review Info

Syntax Quizzes

Quiz 1 - variables, assignment, expressions, output

Expect questions of the following types:

Write only what is asked for - a variable declaration, an assignment statement, an expression, and output statement, respectively. Also remember that the ending semicolon is part of the required syntax for a statement, but is not part of an expression.


Quiz 2 - conditionals

Expect questions asking you to write Java for expressions involving relational and boolean operators, such as:

Also expect questions involving writing if statements, such as:

Include only what is asked for - no variable declarations unless it says "declare a variable...", no assignment statements unless it says "store a value...", and so forth.


Quiz 3 - loops

Expect questions of the form:

As indicated, you'll be provided with the code for the loop body. You may need to declare loop variables. Both while loops and for loops are acceptable.


Quiz 4 - arrays

Expect questions of the form:

In all cases, write just what is asked for — you do not need to declare or initialize any variables unless that is specifically what the question is asking for. For the "write an expression" questions, this is just the expression (e.g. numbers.length or numbers[3]) and not a full statement.


Quiz 5 - subroutines and functions

Expect questions of the form:


Quiz 6 - using objects

Expect questions of the form:

You may be asked to work with the Card, Deck, and Hand classes from section 5.4, or with a new class. You will be provided with the javadoc (or similar) API of any classes you are to use (including Card, Deck, Hand).


Quiz 7 - writing classes

Expect questions of the following form:


Quiz 8 - inheritance

If you can't access the links in the quiz:

Expect questions of the following form:


Final Exam

The final exam will be written (not on the computer) and closed book/notes. It will be cumulative, covering material from the whole course, and will focus on the fundamentals of Java syntax and semantics — how to write things and what it means when they appear in a program — as well as when to use those things. It will be split into two parts (syntax and the rest) and you will need to hand in part 1 before starting on part 2. You will have the full three-hour time period but the exam is not intended to be that long.

The topics covered will be the same as for the syntax quizzes — variables, assignment, expressions, output, conditionals, loops, arrays, subroutines and functions, using objects, writing classes, and inheritance — plus Javadoc-style comments and input using Scanner. Drawing and animation, ArrayList, and abstract classes, interfaces, and instanceof will not be on the exam.

Expect questions that ask you to write code as well as short answer "concept" questions and code-reading questions.

Code-writing questions will focus on syntax rather than algorithm development or problem solving. What you need to write will be more of a matter of translating pseudocode or fairly direct language rather than figuring out how to do something. Expect questions similar to the syntax quizzes, though they may not be as narrowly focused. For example, a question might ask you to write a subroutine (header and body) which takes an integer x as a parameter and prints out "big" if x is greater than 10 or "medium" if x is greater than 3 but less than 10, or to write a class or subclass given a list of its instance variables, constructor(s), and methods. You should understand the terminology used in the syntax quizzes. For example, if you are asked to write an expression, you should include only the expression and not extra. While the focus on these questions is on syntax, it won't be graded quite as strictly as on the quizzes — you won't lose points for the occasional missing semicolon, for example, but major syntax problems or a pattern of small errors (such as many missing semicolons) will count against you.

Code-reading questions might be tracing questions (asking you to do things like write what output is generated by a section of code when it is executed), questions which ask you to describe what happens when a section of code is executed, or questions which ask you to locate and fix syntax errors and/or logic bugs in a section of code. You should understand the core statements (variable declarations, assignments, conditionals, loops, subroutine/function calls, method calls), operators and expressions (arithmetic operators, relational operators, logical operators, creating new arrays and objects), and related aspects (such as that variables hold references to objects rather than the objects themselves, and the consequences of that when an object is passed as a parameter to a subroutine or function, an object is involved in an assignment statement, or when == is used).

Short answer concept questions might involve defining terms, explaining how something works or why the answer is what it is, recognizing when various Java constructs are applicable, ... — anything that isn't reading or writing code. Examples of definition and concept questions include, but aren't limited to:

An API will be provided if you are asked to use any classes.