ulrail.gif

Exam 3 Review

  ur-2c.gif urrail.gif
blrail-nonavbar.gif

Home | Resources | Homeworks | Exams
Slides | Labs | Contacts | Submit | TAs

br-2a.gif   br-2c.gif brrail.gif
spacer.gif spacer.gif spacer.gif

Exam 3 Review

These are the review points from the Jeopardy game played in class during the lecture before the third exam.

Visibilities: Recall that private means that only code within that class can access the field or method.
Visibilities: Recall that public means that any code anywhere can access the field or method.
Visibilities: You don't need to know what protected and package do at this point, though.
Visibilities: The purpose of accessor and mutator method is to allow (and to control) access to private fields
Visibilities: You don't need to know this for the exam (we'll see inheritance on the last day of lecture).

Staticness: You can access both static and non-static methods/fields by the object name (c.radius, c.PI)
Staticness: You can't access non-static (and methods) by class name: which one does Circle.radius refer to?
Staticness: Non-static methods can refer to both static and non-static fields (see Circle's computeArea() for an example)
Staticness: static methods can only refer to static variables (and local variables)
Staticness: No matter how many objects are created (even zero!), there is always one (and only one!) instance of a static field

Parameters: A formal parameter is the name of the parameter in the method declaration.
Parameters: An actual parameter is the value passed into the method call.
Parameters: Java is pass-by-value: a copy of the actual parameter is copied into the formal parameter.
Parameters: If you try to change the value of the parameter in a method, only the formal parameter gets changed; the actual parameter does not.
Parameters: While you can't change the value of an actual parameter, you can change the fields of what it points to.

Misc: The remove() method for a Vector has a return type of Object; therefore we have to cast it back to a String, for example.
Misc: Whenever a method returns a object (such as String), what is really returned is a reference; same thing for arrays.
Misc: If you call x = foo();, and the foo() method has a return 5; statement, then 5 is copied back into x.
Misc: The purpose of a wrapper class (such as Integer) is to allow you to store a primitive value as an object.
Misc: Remember those four things that happen when you create an object!

Arrays: int x[] = new int[5]; is how you create a 1-D int array of size 5.
Arrays: All spots in an array are initialized to default values.
Arrays: When you declare an array x, then x is really a reference.
Arrays: int x[]; declares a reference x, which does not yet point to an array.
Arrays: Remember that you can have multiple algorithms that yield the same answer, but some (such as binary search) operate much faster than others.

2-D Arrays: A ragged array means the columns are of different lengths.
2-D Arrays: String x[][] = new String[6][4] is how you create a 2-D array of Strings.
2-D Arrays: Explicit initialization is when you are specifying the values to go into the array when the array is created: int x[][] = { {1, 2}, {3, 4} };.
2-D Arrays: Arrays cannot be resized - once created, they can never change size.
2-D Arrays: You don't need to know who the president of UVa is for the exam.

spacer.gif
spacer.gif footer-middle.gif spacer.gif