What to review for the first quiz
-
The quiz will be on Feb. 19.
- The material is cumulative: what we cover in class + the prerequisite material. Review class notes, homework 0 and underlying topics of any questions that were difficult. No graphics, no gui (javafx), no file processing.
- Format: Short answer questions, plus one long programming problem.
Question types:
Possible short answer questions:
- Evaluate expressions, e.g. (3 < 4) evaluates to boolean value true, (3 + 4) evaluates to int value 7, "hello"+3+4 evaluates to String value "hello34". Expressions are composed of operands and operators. Operands may be variables, values and values returned by method calls. Operators may include logical operators (&&, ||, !), equality operators (==, !=), relational operators (<, <=, >, >=), assignment operator (=), arithemetic operators (+, -, *, /, %), integer vs. floating point operations (e.g. 7/2 evaluates to 3, 7.0/2 evaluates to 3.5, 7/2.0 evaluates to 3.5, 7.0/2.0 evaluates to 3.5), data conversion (widening vs narrowing e.g. casting: (double)7/2 evaluates to 7.0/2 = 3.5).
- Identify terms e.g. data type, variable, class, object, literal, method, parameter.
- Trace or write code that may include declarations, assignments, conditional statements (if, if-else, nested/cascaded if), repetition (while, do, for loops), comparing data (comparing primitive integers/characters using ==,
comparing floating point numbers by checking to see if the difference between them is less than a small value, i.e. a tolerance, comparing objects using equals method), arrays, parameter passing (passing primitive variables vs. objects to methods, e.g. HW0 problem 9, handout of ParameterPassing program (see
lab exercises)).
- Design and implement a method that invokes other methods (either predefined in the Java API, or your own helper methods). This is method decomposition (e.g. HW0 problems 10, 11, 7 and lecture exercises (computeAverage method calls helper method computeSum) and (checkPalindrome method calls helper method reverse)).
- Write or evaluate tests using JUnit methods assertEquals or assertTrue or assertFalse (e.g. lecture exercises).
- Write or evaluate a comment for a method (e.g. lecture exercise)
- What is the output produced by the following Java code?
- Write a method, loop, statement or expression that does what is specified.
Long answer question:
Write a class named _____ with instance data (attributes / state variables) to represent ___,
a constructor to initialize the instance data, methods that _____, and driver code
(e.g. JUnit test method, or a main method in a separate class)
to create objects and call the methods appropriately on those objects.