A: Goes to a endless loop (missing and x=x+1)
B: Missing the start of the program, "class Excercise 1b{}"
C: Missing psvm
A: Missing "TapeDeck t = new TapeDeck", output: "tape playing" //ln// "tape recording"
B: Missing method "playDVD" (can just remove line d.playDVD;), output: "DVD recording"
A: Missing the creation of new books for every book in the array! (Books myBooks[x]=new Books())
B: It's trying to create a object that's not in the bounderies of the array (array[3] -> 0-2, gona make object 3)
See if the files will compile, how to fix and what is their output...
A: Everything is ok here (i couldn't find and error with is the solution)
B: public/private? -> the problem was that getters need to have a defined type (i didn't manage to notice that... :S)
Instance variable, argument, return, getter, setter, encapsulation, public, private, pass by value, method
- "A class can have any number of these." -> instance variable, getter, setter, method
- "A method can have only one of these." -> return
- "this can be implicitly promoted." -> ??? (argument, return, they can be a smaller type then the output type)
- "I prefer my instance variables private." -> encapsulation
- "It really means "make a copy" -> pass by value
- "Only setters should update these" ->
prvate(correct is instance variable :S) - "A method can have many of these." -> argument~~, instance variable~~ (correct is only argument :O)
- "I return something by definition" -> ~~return (method, ~~getter) / correct is getter
- "I shouldn't be used with instance variables." -> public
- "I can have many arguments." -> method
- "By definition, I take one argument." -> setter
- "These help create encapsulation." -> getter, setter, public, private
- "I always fly solo." -> return
i have to connect 4 blocks of code to the right output (7 outputs, not all are correct and not all codes are correct)
(answers are a little jumbled in the book -> for the 3rd and 4th code blocks)
- the first code will print the "B m1", "A m2", "A m3" -> 2nd output
- the 2nd code will print "B m1", "A m2", "C m3", 13 -> 4th output
- the 3rd code will print "A m1", "A m2", "C m3", 13 -> 7th output
- the 4th code will print "B m1", "A m2", "C m3", 13 -> 4th output
- True
- False -> return type is wrong
- False -> doesn't override the frighten method
- False -> parametar is a byte isntead of int