Week 3 Part 2 Flashcards
When a parameter is passed to a method, it is known as
an argument
Classes that are compiled in the same directory are considered to be in the same _______
package
Most classes in Java programs need to be imported __________, by typing ______ followed by the class name
explicitly, import
think import java.utl
Classes that are in the same package, are they imported explicitly or implicitly?
Implicitly
For classes, what other situation is there where an import declaration is not required?
Not required if the class is referred to with a full qualified method name, including its package and class names.
Describe UML design. How many compartments? Where is the class name? Where are the class attributes? What are attributes? Where are the class operations? What are class operations?
3 compartments, class name in the top one. Class attributes in the second, which correspond to instance variables. Class operations in the third, which correspond to methods and constructors.
How are instance variables represented in UML?
-name:type
How are operations represented in UML?
A setter for example
+setName(name:type)
Apparently everything you learned in semester 1 is wrong. In UML do operations that don’t have a return type have a return value? (void)
Apparently not. If they do have return value it looks like this +getName():type
What happens if a class does not define constructors? What happens to the classes instance variables if this is the case?
The compiler provides a default constructor with no params. The instance vars are initialized to their default values
T/F - A default constructor will still be created if there is a declared constructor
False
T/F - Java requires a constructor call for every object that is created
True
T/F - Constructors specify return types
False
How does UML distinguish a constructor from class operations?
Places the word constructor between Guillemets “«_space;»” pronounced GILL MITTS
«constructor»Account(name:type)
How does a compiler select the appropriate method to call when there’s overloading? What is this called? Explain the mechanisms behind this function
Inspects the:
number of arguments
types of arguments
order of arguments
It’s called the Method signature