CS1 Quiz 2 Preparation Guide

·         Writing Classes/Methods

o        Know the syntax for writing a class.

o        Given a program specification, such as the javadoc for the class, be able to write a class stub.

o        Once you have written a class stub, be able to fill it in!

o        Be able to distinguish between whether a variable is a class variable or an instance variable

o        Be able to determine if such a variable (above) should be private or public

o        Know when to use local variable declarations for method implementation.

o        You WILL have to write one!

o        You might have to write a test program for the class you write!

·         Constructors

o        Know what role constructors play in a class.

o        Know what is different about the header of a constructor versus a method.

·         Scope and lifetime

o        Know which variables are known where (You will need to trace programs where this is important.)

o        Understand the use of "this" and when it's needed.

·         Parameter Passing

o        Understand the relationship between formal and actual parameters (arguments).

o        Know which method is chosen if the method is overloaded.

o        Understand the difference between passing a primitive type and an object.

·         Control Structures

o        Selection Statements

§         evaluating boolean expressions

§         Relational Operators: <, ><=, >, >=, ==, !=

§         Logical Operators: &&, ||, !, ^

§         Know the precedence of relational and logical operators

§         Be able to write boolean expressions

§         Be able to evaluate boolean expressions

§         if

§         Sytax of all of the different forms an if might take

§         Nested ifs and dangling elses

§         Be able to trace any form of if statement (i.e., provide the output from it's execution)

§         switch

§         Sytax

§         Use of break

§         Be able to trace a switch statement (i.e., provide the output from it's execution)

§         Be able to write an equivalent single if statement from a switch statement.

§         Be able to write an equivalent single switch statement from an if statement, if it's possible.

§         Know when you can't do the above!

o        Repetition Statements

§         While loop

§         Syntax

§         Be able to trace the execution of a while loop

§         Be able to write one from a description

§         Be able to write a while loop that is equivalent to a do while loop or to a for loop

§         Do while loop

§         Syntax

§         Be able to trace the execution of a do...while loop

§         Be able to write one from a description

§         Be able to write a do...while loop that is equivalent to a while loop or to a for loop.

§         For loop

§         Syntax

§         Be able to trace the execution of a for loop

§         Be able to write one from a description

§         Be able to write a for loop that is equivalent to a do while loop or to a do...while loop

§         Know when the above is NOT possible.

§         Nested loops

§         Be able to trace

§         General

§         Which loop are pre-test loops and which ones are post-test loops?