Exam 2 Review Fall2007:Java Keywords Faceoff
Post your questions here.
Back to Exam Review 2
Here's what I know, feel free to add to the list guys. There's no penalty for putting answers on here and it helps everyone out.
static v. nonstatic (instance) - static methods take in arguments instead of variables.
for example (these are not real methods)
myMethod1(7) is a static method because it takes in an argument, 7, something that never changes (you can't say 7 = 8 or something)
myMethod2(someName) is a nonstatic instance variable because it depends on what you set someName (someName can equal 7, "Bob",etc. it's not constant)
- Uh this is completely wrong. A static method is one that can be called without having to declare an instance of the class that it is held in. Examples of static methods include FileChooser.getMediaPath, FileChooser.setMediaPath, Math.random, and etc. Notice how we never had to say FileChooser fc = new FileChooser() anywhere when using these methods. Dawn Finney.
linked list v. array - these are two different types of structures, except linked lists are dynamic and arrays are static. With an array, you must define the number of elements in it as soon as you create it (fixed length). With a linked list, you can easily add and remove elements (dynamic length).
null v. void - this one's kind of hard to explain. First, void means Do Not Return Anything. null means there is something deemed as the return, it just happens to be a nonvalue, nothing. Say you type
LLNode node = null
There IS a LLNode node declared, it just happens to be null (no value,no phrase, no string, no nothing)
It's kind of like an empty placeholder in this sense.
That's all I got, add to the page people!
- void is only applied to methods that do not return anything. null is more like a non-value or "this object is undefined at the moment" and is only applied to objects. Dawn Finney
extends vs. implements:
extends-automatically has a class inherit functionality from a superclass
implements-forces a class to require functionality from an interface
Link to this Page