|a) The error will be "Datatype mismatched" because the data type "integer" does not accept words.|
|c) I think the method should return void because this type of method usually just modifies the original version instead of creating a copy. I dont know about the static part however...I don't think it should be static...should it?|
|d) I think the class can extend picture and still work but I don't think its necessary to do this because the picture class and its methods are already public.|
|Looking at the Midterm Review I have a couple of questions.|
from part (b), Problem 7 (Understanding Java Types):
I cannot clearly say why the first expression will not work. Is it because you are not allowed to declare a new variable while calling a void method?
String s = "string";String = String. Both sides of the equation are Strings.
int counter = 0.05;Here we have int = double. The two sides are not the same, hence an error. REMOVEDke Mark hinted at above, what does newpic = void mean? Dawn Finney
|from part(c), Problem 7 (Understanding Java Types):|
I believe that you should declare the method void because there is no data to return. I am not sure however if the method should be static. If the method is static then is does not require any instances? What is an instance exactly?
|from part(d), Problem 7 (Understanding Java Types):|
Does this question deal with inheritance from Picture? I'm not sure what the question is asking. When you ask "and still compile?" are you asking if we will be free of errors if we attempt to compile?
|b) because it says void increaseRed will still do its job-to increase red- however, it will not return the picture back (it will still compile and execute though). I do not think that you will get any error. In regards to the other one about size, it will return a picture. Also, I'm kind of confused about the feedback Prof. Guzdial gave above. If you could provide some clarification, I would be extremely grateful.|
|c) I'm kind of confused about the 'staticMethod()' thing Prof. Guzdial was talking about. I don't think it should be static because you do need an instance of the class. For example, you are going to use 'this' sometime in your code, right?|
|d). If we say PictureCollage extends Picture we are adding to what pictures will know what to do. It creates another method (PictureCollage) that pictures will now know how to do.|
|d.) PictureCollage can extend Picture and still compile. The collage would stil work but this is not a good idea because you really don't need your PictureCollage to inherit everything that Picture knows how to do.|
|d. Its because PictureCollage returns a certain picture collage. Its not a class with different components. Plus, PictureCollage is a public static void main (Stringargs) so its kind of running a particular program. You can't use it to make a different collage than the one in the program. Picture is different because you use the methods in Picture on different kinds of pictures.|
|B. I know the void one will not work because you're saying that newpic=void which is an incorrect statement. The one that is declared Picture still wouldn't work thought because you would be redefining smallpic.|
|(b.) No, because void functions only change the original picture? They don't return new pictures?|