Unix will never be an exam topic; I will not ask questions about Unix commands, Unix file system, vim, etc.
variables: ----------- storage locations for specific types of data (type is important) need to be declared need to be initialized before used assign a variable an initial value know how to read in input value: Scanner reader = new Scanner(System.in); int x = reader.nextInt(); // or .nextFloat(), .nextDouble(), .nextLine(), know how to assign an object reference a value: String str1 = new String("hello"); String str2 = null; str2 = str1; // str1 and str2 point to the same String object statements: ---------- method calls System.out.println("blah " + 3); x = reader.nextInt(); assignment statements var = value of expression; the expression, rhs, can contain a method call type is important! evaluating expressions: ----------------------- know how to evalute and write arithmetic and boolean expressions know the difference between int and float or double operations know the arithmetic operators know the precedence rules boolean expressions (know the logical and relational operators) constants --------- know how to use and why they are used in programs. know how, and where, to define them: public class TestClass { public final float MAX = 3.6; public final int NROWS = 4; public static void main(String[] args) { ... loops and conditional stmts --------------------------- know how to write for loop, while loop, and if-else stmts, and know how to trace through a switch stmt (I won't ask you to write one) know how for and while loop are equivalent (can translate one to the other) nested loops Using objects: ------------- Foo f; // f is a reference to a Foo object f = null; // null is a special reference value (refers to nothing) if(f == null) { ... // we can test f's value to see if it is null new: use new to create a new Foo object, new calls one of Foo's constructors ---- f = new Foo(x, y); use dot to access the Foo object's public data members or methods String s = f.getName(); f.setName("Tia"); Know these classes: String, Math, Random ------------------- I'll give you a list of the methods from these classes (the method signatures) , but you should know what the methods do and how to call them Static methods: associated with the class not the object --------------- double result = Math.sqrt(3.5); Writing your own classes ------------------------- A class is type definition for set of related objects need to define (1) data part and (2) services part (methods) public class MyClass { data members should be private ------------------------------ private int _age; private String _name; private String _addr; methods: -------- + implement services of objects + important for modular code design + code re-use + the black box idea: take input, perform a computation, return a result There are different types: (1) Constructors public MyClass(param list) { ... } (2) Accessors and Modifiers (provide access to private data members) (3) Other methods that implement a service provided by an object public String toString() { ... public int compareTo(MyClass mclassref) { ... // and others (4) Static methods are associated with the class not with individual objs if method doesn't use object state, then it could be static // main is an example of a static method, public static void main(String[] args) { method definition: ----------------- public return_type MethodName(par1_type par1name, par2_type par2name, ...) { local variable declarations stmt1; stmt2; ... return (expression of type return_type); } method call semantics: how arguments are passed to parameters stack allocation/deallocation as call/return from methods scope rules: when a variable name has meaning how method returns a value to its caller void methods do not return a value method can call method can call method... know what happens with the stack and with scope rules Arrays: ------- * ordered, homogeneous collection of data * arrays are objects, but they have a special syntax for accessing bucket values and for creating * actual size (total capacity) vs effective size (amt. currently using) * declaring and accessing array buckets: float[] farray; farray = new float[20]; // create a new float array object with 20 buckets // each bucket stores a float value farray[4] = 6.3; // index must be an int farray.length // data member length, stores array's actual size * for loop index often used to access all array buckets in some way * passing arrays to methods: like passing any other object to a method should always pass array's effective size public int foo(int array[], int size) { ... } call: int[] array1, array2; // initialize both in some way int x = foo(array1, 5); int x = foo(array2, 5);