home—info—exams—lectures—labs—hws
Recipe—Laws—lies—syntax—java.lang docs—java.util docs
exam2-study-questions
exam2 study sheet
2007.Fall
Exam1 is scheduled for class on Oct.25 (Thu).
The exam will be in-class, on-paper, closed-computer.
It will consist of questions very much like these questions,
the homeworks, and labs.
Some of the questions may be directly from these sources.
The single best way to study for the exam is to sit down and
re-work homework and lab questions from scratch.
The material from Exam1 won't be especially tested,
but due to the cumulative nature of the material, you should
know all the topics from the exam1 study questions.
New Topics
- Composite objects
- References are values
- equals vs. ==
-
Know the difference between ==
vs. customized, class-specific methods commonly named .equals.
- public vs. private
- static method (but not static fields)
When giving a java expression or definition,
you should be able to type it into BlueJ's Code Panel without any error;
this means knowing where you need parentheses, where you need squirly-braces,
and where you need semicolons (though I'll give some slack on these).
I particularly recommend the problems which require actual code
or definitions.
- Review the lecture notes, and write for yourself any
of the sample programs/exercises therein.
- Review the labs, and write (from scratch) any of those programs again.
- Review the homeworks, and write (from scratch) any of those programs again.
- While not intentionally cumulative,
all the concepts from the exam1-study-questions—exam1 study sheet: 2007.Fall
are still pertinent.
- What is the mantra for calling a regular (non-static) method?
What about for a static method?
- What is the mantra for a function's signature?
What adjectives might come in front of the signature?
-
A Circus has a name,
a ticket-price,
an EmCee,
two Dogs,
and a PizzaServer
(each as used in various lectures and labs).
-
Write the fields for class Circus.
-
Write a constructor which takes three inputs:
the name of the circus,
the ticket price (in dollars),
and one Dog which is in that circus.
It creates a new circus which has a Pizza Server who went to
Highwire High School,
and whose other dog is named “firejumper”.
-
At the code pad, how would you
declare a variable to hold a Circus.
-
At the code pad, how would you
call the circus constructor and store the result in your variable.
-
Draw a picture of what things look like,
after calling the constructor.
-
Write the Circus method boolean isCheaperThan(Circus other).
(You can assume that all pertinent getters/setters have been written.)
-
Write the Circus method Dog oldestDogIn().
-
Write the Circus method Circus betterOf(Circus other).
One circus is better than another if it has a bigger “cool factor”,
where the cool factor is the age of its oldest dog minus
its ticket-price.1
(Even if you didn't write the previous two methods,
assume you can call them for the sake of this problem.)
-
The following statement doesn't make sense. Why not?
String m = System.out.println( "hi" );
-
What is the value of
(new String("cat") + new String("hay")) == new String("cathay")?
Confirm by typing this expression into Code Pad.
Explain why that is the answer (1 short sentence).
-
What is the value of
(new String("cat") + newString("hay")).equals( new String("cathay") )?
Confirm by typing this expression into Code Pad.
Explain why that is the answer (1 short sentence).
What if we use "cat", "hay",
and the proper noun "Cathay"?
-
What is the value of
new String("cat") + (newString("hay").equals( new String("cathay") ))?
Confirm by typing this expression into Code Pad.
Explain why that is the answer (1 short sentence).
-
true or false?:
It is possible to write a method swapDoubles such that
the last line below is true:
double x = 5.0;
double y = 7.0;
swapDoubles( x, y );
(x == 7.0);
|
-
Draw a picture of the object (and object references) involved
during a sequence of calls to
Dog's swapSoundsWith.
-
Draw a picture of the object (and object references) involved
during a sequence of
calls to
Cat's badClone method,
and a working clone method,
from lect09c.
-
Draw pictures of what all the existing (references to) objects
look like, after each of the following five lines, based on
your
hw08-soln
Explorer me = new Explorer( "Dora" );
Treasure t1 = new Treasure( "a singing map", "It guides you: over, around, and up.", 0.05, "");
me.grab( t1 );
me.grab( new Treasure( "a collideascope", "Like a kaleidoscope, but more dangerous.", 1, "" ) );
me.dropLeft();
|
(Assume that if both pockets are free,
new Treasures are put into the left-pocket,
if both pockets are free.)
-
Review all lab exercises,
and problems mentioned on lecture pages (whether or not a solution is provided).
Any of those problems are
fair game for the exam.
-
Book exercises 5.1-5.9,
5.13,5.15,5.17, 5.19.
The self-review questions tend to be good, although we've not
talked about loops or overloading.
Note that the book makes heavier use of java.util.Random
than we have. (It's difficult to write test cases for!)
You can see the standard bototm-of-page link for “java.util docs”.
-
Book exercises 4.1 - 4.6.
You can also look at the self-review questions (up through 4.7a).
We've not talked about loops.
-
Book exercises 3.1 - 3.9 (excluding 3.5).
Self-review exercises are good SR3.4-3.6 and SR3.16,
Note that we haven't talked about
printf, and to answer some of the questions
means looking at the documentation for String
and/or Random (follow the top-of-page links for
documentation of java.lang and java.util,
respectively).
1That is --
it's cool to see an old dog, but not if it costs a whole lot more. ↩
home—info—exams—lectures—labs—hws
Recipe—Laws—lies—syntax—java.lang docs—java.util docs