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

Midterm exam 1 review Fall2006: Understanding Java Types

Back to Midterm Exam 1 Review Fall2006

Questions? Answers? Comments?



Correct me if i am wrong
for (a). it would create an error, 'data type mismatch', is it true? i havent try it in java, but in c++, it should be data type mismatch, since fred is declared as integer, but if we try to put string inside, it would create error.

That's exactly what would happen, except the actual error that DrJava gives is: "Error: Bad types in assignment" REMOVED Cormack

(b). the increase red will not work since it doesnt return anything, at the second part, cascading will work since we know that scale() return a picture
(c). void since it return nothing, or atleast we expect it return nothing,
nonstatic, since we have instance in class exist
(d). Yes, i dont know why it compiles ;)
no, useless, because it is redundant..

//btw that was me ;) chris ang

so what's the answer to the d) part...?

The answer to part D) is yes, it compiles. The collage will still work, because it will overwrite the methods used in the Picture method. But it's not a good idea, because it's bad coding logic.

That's what I think they said in class Wednesday.

REMOVED



Link to this Page