Change Contents of the Bubble
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Midterm exam 2 review Sp2005: Java, Java, Java, says George

Back to Midterm Exam 2 Review Sp2005

Questions, comments, answers, etc.



B. Event - mouse click, something that happens when user does something, like a trigger. ActionREMOVEDsteners listen for events. It is an abstract class that describes the behavior of the event.
C. Sream - allows user to access files, a sequence of data. You could listen to the traffic on a modem or read raw data.
D. Casting - instances where inheritance is involved. It tells an object to behave a certain way regardless of class and subclasses.

B is pretty good. C's first sentence is fine, but I don't grok the second one. D is in the same ballpark but would only earn partial credit. Try giving me an example of casting. When can you cast and when can't you? Can I say
(String) 12
? But I can say
(Agent) simulation.getAgents().get(0)
? Why? Why does that last one work? What's it doing? Mark Guzdial


only if what you're casting as and what you cast are related by inheritance?

a.) They are two kinds of layout managers, BorderLayout places the buttons or whatever in "north, south, East,West, center" locations, and the center gets extra space.... Flowlayout arranges them from left to right..and none of them get extra space. More generally these are all "renderers"

b.)An Event is an object that represents an action, Its like a mouse click, pressing return or something else that acts as a trigger. ActionREMOVEDsteners listen for events, They define the functionality that other classes implement


c)A stream is a sequential stream of bits and is used by java to handle imput and output, you could write a text file if you wanted

d)Normally Casting is used when using a class that is a subclass of a more general class.. In the above example, 12 will and always be an integer, 12 is not a subclass of string... but in the next example, Simulation is the general class while Agent is the Subclass. simulation contains agent, it just won't return it unless it is "casted" to do so.



Link to this Page