Field correct answers a member variable or data stored by an object
method correct answers a member function of the class that may operate on fields
References correct answers All objects are accessed by references
Type promotion correct answers Converting from a smaller to larger, can do implicitly
double weight = 200;
Type demotion correct answers Converting from larger type to a smaller one
Must cast
int height = (int) 10.99
Automatic garbage collection correct answers Objects with no references to them are
automatically deleted
static method correct answers can be called on the class with no object. Also called class
methods
static field correct answers Shared by all instances of the class
Pass by value correct answers Passing a primitive type passes its value
Passing an object passes (by value) a reference to the object
When passed an object, state can be modified
What object it points to cannot be changed
Arrays correct answers Fixed size when created
Generic correct answers works with different types of objects
Collections correct answers Only stores objects, no primitives
Use Wrapper classes such as Integer
String correct answers Compare using .equals()
== compares the reference
Immutable, cannot be changed once created.
,Scanner correct answers Keyboard input done via Scanner
Scanner scanner = new Scanner(System.in);
System.in does not need to be closed, don't close a Scanner created from System.in
Files correct answers File(filepath)
Represents a single file on disk (by path)
Scanner(File)
does reading, use .hasNextInt() .nextInt()
PrintWriter(File)
does writing, use .println()
Static factory method correct answers A static method which creates an object
Like a constructor, but more flexible. Can give a descriptive name
Formatted printing correct answers Use printf()
System.out.printf(<format string>, arg0, ...);
System.out.printf("%s! Is it %b that you're %d?%n", "Waldo", true, 42);
Waldo! Is it true that you're 42?
Wrapper correct answers A class to hold a primitive value
Interface correct answers A set of methods a class can choose to implement
FileFilter correct answers FileFilter filter = new FileFilter() {
@Override
public boolean accept(File file) {
}
};
Anonymous class correct answers Instance of an unnamed class which is defined on the fly
Sorting correct answers java.util.Collections.sort();
Elements in the collection must implement the Comparable (generic) interface
@Override
public int compareTo(Object other)
, defines the natural order
Comparator correct answers @Override
public int compare(Object o1, Object o2);
Domain correct answers The industry or area of the system
OOD and change correct answers OOD works well with software change because classes
represent stable problem domain concepts
Requirements gathering correct answers Create a complete description of what the software
product is to do
Phase 2 OOD correct answers Goal: Identification of classes, their responsibilities, and
relationships among them.
Products: Diagram of classes and relationships
Text description of classes
OOD challenges correct answers Need a good design to implement the system
You need to implement the system to know if you have a good design
Sloppy: make many mistakes and mis-steps
Heuristic process
Use rules of thumb vs fixed process
Implementation correct answers Goal: Program test and deploy the software product
Process options
Skeleton code: Implement minimal parts/features of full system first, then flush out code
Component wise: Implement one class/component at a time
Integration: Gradual growth of the system by continually integrating changes
Object correct answers A software entity with state, behaviours to operate on the state, and
unique identity
State: All information an object stores
Behaviour: The methods or operations it supports for using and changing its state
Identity: Able to differentiate two identical objects
Class: The type of a set of objects with same behaviours and sets of possible states