CS 124-02, Fall 2021
Information on the Second Test
The second test for this course takes place in class on Monday, November 1. The material for the test includes everything that we have covered from the textbook, up through Section 5.2. There will not be any questions that are specifically about material that was covered on the first test. But of course you still need to know how to use the basics: types, variables, assignment statements, control structures, and arrays. The format will be similar to the first test. Questions can incude programming problems, definitions, questions that ask you read and understand some code, and essay-type questions.
The main topics for the test are subroutines, classes, and objects. I will certainly ask you to write one or two subroutines. I might give you a subroutine or a class and ask you to use it or explain what it does. However, I will not ask you to write a complete class. There will be no questions on this test that use JavaFX or any kind of graphics. Also, ArrayLists and the Random class will not be on the test.
From the textbook, the test covers all of Sections 4.1 through 4.4. We did not cover any part of Section 4.5. We only covered certain things from Sections 4.6 through 4.8. From Section 4.6, you only need to be aware of packages and Javadoc. From Section 4.7, you should know something about preconditions and postconditions. From Section 4.8, you should know about the final modifier, named constants, and combining initialization of variables with their declaration. We covered all of sections 5.1 and 5.2
Here are some things you should know about:
black box implementation of a black box interface of a black box how black boxes help to manage complexity subroutines as black boxes the idea of modularity. subroutines (also known in Java as "methods") writing subroutines: the syntax for subroutine definitions the access modifiers public and private return type of a subroutine void parameter list of a subroutine calling a subroutine; what the computer does when it executes a subroutine call statement formal parameters in a subroutine definition (also called dummy parameters) actual parameters (in a subroutine call statement) type rules for actual parameters how actual parameters are passed into a subroutine local variables in subroutines global variables functions (subroutines that return a value) returning a value from a function calling a function and using its return value the return statement in a function: return <value>; type rules for the return value of a function using a return statement in a void subroutine throwing exceptions in subroutines IllegalArgumentException using subroutines with arrays: arrays as parameters and return values preconditions, postconditions, and how they are used to reason about programs Javadoc comments and why they are used packages; what it means for a class to be in a package importing classes from a package combining declaration with initialization; for example: int x = 17; final variables named constants and the reasons for using them classes and objects the relationship between classes and objects creating objects from classes with "new" instance of a class (an object created from that class) instance variables and instance methods static versus non-static static things are part of the class non-static things don't exist until an object is created, and each object gets its own copy instance variables: the non-static global variables in a class instance methods: the non-static methods in a class how the non-static part of a class is used when objects are created from the class pointers to objects (also called references) null classes are types, so can be used to declare variables, return types, and parameter types arrays of objects; an object type can be the base type of an array when an array is created, whose base type is an object type, all values in the array are null declaring a variable (of object type) does not create an object a variable (of object type) can never hold an object, only a pointer to an object an assignment statement applied to objects will only copy a pointer, not an object testing pointers to objects with == and != tests whether they point to the same object controlling access to instance variables by making them private getters and setters and why they are used the toString() method in a class constructors how to recognize constructors in a class definition parameters in constructors calling constructors with "new"