CSC 221: Computer Programming I
Test 1 Review


Overview & history hardware vs. software historical generations mechanical -> vacuum tube -> transistor -> IC -> VLSI -> parallel & networks evolution of programming machine language -> assembly language -> high-level language Using Java classes loading a BlueJ project, creating an object, inspecting an object's state calling a method, parameters, data types (String, int, double, char, boolean) Java class definitions fields: maintain the state of an object constructor(s): initialize the fields for a newly created object methods: implement the behaviors of the method accessor method returns a field value; mutator method changes field(s) class/constructor/methods are declared public; fields are declared private comments (/** ... */ or // ..) are for documentation, ignored by the compiler Java statements assignment statements variable: a name that refers to some value (stored somewhere in memory) right-hand side can be a value, variable, or expression (using +,-,*,/) arithmetic assignments: +=, -=, *=, /=, ++, -- output statements System.out.println displays text to a window on the screen return statements evaluates and returns specified value when executed if statements selectively execute code based on a condition (Boolean expression) if statement (1-way), if-else (2-way), cascading if-else (multi-way) comparison operators: ==, !=, <, >, <=, >= (danger: = vs. ==) logical connectives: && (AND), || (OR), ! (NOT) method calls internal call (to another method of same class): METHOD(PARAMETERS) external call (on another object): OBJECT.METHOD(PARAMETERS) input values in method call match parameters based on order Variables and memory fields: variables that maintain the state of an object of that class persist as long as the object exists, accessible to all methods if want a single field to be shared by all objects in a class, make it static parameters: variables that store values passed to a method (allow for generality) persist only while the method executes, accessible only to the method local variables: variables that store temporary values within a method persist from point they are declared to the end of method execution primitives types vs. object types to store primitive type: must declare and assign value to store an object: must declare, call constructor and assign result Object-oriented design goals abstraction: ability to ignore details to focus attention on higher level of problem modularization: process of dividing a whole into well-defined parts, which can be built/examined separately, and which interact in well-defined ways