Q: Java: A variable contains either a reference to an object or a [...]
A: primitive value

Q: Java: A variable either contains a primitive value or [...]
A: A reference to an object.

Q: Java: Are arrays always mutable?
A: Yes.

Q: Java: Are boolean fields automatically initialized?
A: Yes, to 'false'.

Q: Java: Are floating-point fields automatically initialized?
A: Yes, to zero.

Q: Java: Are hex literals case sensitive?
A: No.

Q: Java: Are integer fields automatically initialized?
A: Yes, to zero.

Q: Java: Are Java arrays zero-based or one-based?
A: zero-based

Q: Java: By default, classes are assumed to belong to the [...] package
A: java.lang

Q: Java: Can a field be declared both volatile and final?
A: No.

Q: Java: Can a file contain multiple class definitions?
A: Yes.

Q: Java: Can a final field be declared volatile?
A: No.

Q: Java: Can a variable name begin with a digit?
A: No.

Q: Java: Can a volatile field be declared final?
A: No.

Q: Java: Can you fix an array's size in its declaration?
A: No.

Q: Java: Can you make an array immutable?
A: No.

Q: Java: Comments between /** .. */ are [...]
A: javadoc documentation

Q: Java: Do blank finals receive a default initialization?
A: No.

Q: Java: Does case matter in class and file names?
A: Yes.

Q: Java: Does Java have unsigned integers?
A: No.

Q: Java: Give two ways to declare 'foo' as an array of integers
A: int[] foo
A: int foo[];

Q: Java: How are Java statements terminated?
A: With a semicolon.

Q: Java: How are Javadoc comments delimited?
A: /**  ...  */

Q: Java: How are multiline comments delimited?
A: /*  ...  */

Q: Java: How are one-line comments delimited?
A: // ...  LF

Q: Java: How can you find out the size of array foo?
A: foo.length

Q: Java: How do you assign a class to a package?
A: With a package declaration.

Q: Java: How do you run a Java application?
A: > java class args

Q: Java: How do you use a marker interface to test a class for set membership?
A: With the instanceof operator.

Q: Java: How do you write an applet?
A: Create a subclass of java.applet.Applet

Q: Java: How many bits does a 'char' have?
A: Sixteen.

Q: Java: How many bits does a 'long' have?
A: Sixty-four

Q: Java: How many bits does a 'short' have?
A: Sixteen.

Q: Java: How many bits does an 'int' have?
A: Thirty-two.

Q: Java: How many non-public classes may be defined in a file?
A: any number

Q: Java: How many primitive data types does Java have?
A: four

Q: Java: How many public classes can be defined in a file?
A: at most one

Q: Java: How many reserved words does Java have?
A: Forty-eight.

Q: Java: How MUST accessors be named in JavaBeans?
A: getXxx() and setXxx()

Q: Java: In Java, everything is part of a [...]
A: class

Q: Java: Is 'friend' a Java keyword?
A: No.

Q: Java: Is 'include' a Java keyword?
A: No!

Q: Java: Is an array of objects automatically initialized?
A: Yes, with nulls.

Q: Java: Is an array of primitives automatically initialized?
A: Yes, to the default value for that type.

Q: Java: Is it possible to cast a boolean to a double?
A: No.

Q: Java: Is it possible to cast a boolean to a float?
A: No.

Q: Java: Is it possible to cast a boolean to a long?
A: No.

Q: Java: Is it possible to cast a boolean to an int?
A: No.

Q: Java: Must you import a package in order to use its classes?
A: No.

Q: Java: Packages from Foodyne.com are named [...]
A: com.foodyne.*

Q: Java: Packages in the standard Java library are named [...]
A: java.*

Q: Java: Should a function which returns arrays ever return null?
A: No; it should return a zero-length array.

Q: Java: Static variables are also called [...]
A: class variables

Q: Java: What are the two floating-point types?
A: float & double

Q: Java: What character set is used for Java variable names?
A: Unicode

Q: Java: What characters may start a variable name?
A: letters, _ and $

Q: Java: What does a package declaration look like?
A: package foo.bar;

Q: Java: What does the 'import' statement do?
A: It adds a package's classes to the default namespace.

Q: Java: What is a 'blank final'?
A: A final field not initialized in its declaration.

Q: Java: What is a marker interface used for?
A: Tagging a class as a member of a set.

Q: Java: What is the 16-bit integer type?
A: short

Q: Java: What is the 8-bit integer type?
A: byte

Q: Java: What is the base class for all applets?
A: java.applet.Applet

Q: Java: What is the bytecode compiler called?
A: javac

Q: Java: What is the fully qualified name of the Math class?
A: java.lang.Math

Q: Java: What is the signature for the 'main' method?
A: public static void main(String[] args)

Q: Java: What is the value of an uninitialized object reference?
A: null

Q: Java: What Java keyword is used to make a package's namespace visible?
A: import

Q: Java: What Java type is a 32-bit integer?
A: int

Q: Java: What Java type is a 64-bit integer?
A: long

Q: Java: What makes a class an applet?
A: Being derived from java.applet.Applet.

Q: Java: What makes Java persistence 'lightweight'?
A: The serialize method must be invoked explicitly.

Q: Java: What might an empty interface be used for?
A: A marker interface.

Q: Java: What primitive types can be cast to/from boolean?
A: None.

Q: Java: What standard program disassembles bytecodes?
A: javap.

Q: Java: When is an array's size determined?
A: When it is created using the 'new' operator.

Q: Java: When must a blank final be initialized?
A: In every constructor.

Q: Java: Where must a package declaration appear in a file?
A: as the first executable statement

Q: Java: Where must import statements appear in a file?
A: Before any class definitions, but after any package declaration.

Q: Java: Why don't #ifdef, etc., work in Java?
A: Because Java doesn't have any preprocessor.

Q: Java: What method is used to test whether two different objects are equal
A: equals()

Q: Java: Are increment & decrement atomic?
A: Generally not.

Q: Java: Can objects in numeric wrapper classes be used as lvalues?
A: No.

Q: Java: Can values in numeric wrapper classes be changed?
A: No.

Q: Java: How do wrapper class names differ from primitive data type names?
A: They are capitalized.

Q: Java: How do you literally initialize an array of primitives?
A: With a comma-delimeted list enclosed in curly braces.

Q: Java: How do you specify a unicode character?
A: \uxxxx

Q: Java: How do you specify that a numeric literal should be interpreted as a 'float'?
A: Append an 'F'.

Q: Java: How do you specify that a numeric literal should be interpreted as a long?
A: append an 'L'

Q: Java: How do you test a reference for nullity?
A: if (ref == null) ...

Q: Java: How do you test two Strings for equality?
A: You use the 'equals' method.

Q: Java: How do you test whether a result has value NaN?
A: Use the isNaN() method of the Float or Double class.

Q: Java: How do you write a numeric literal in hex?
A: with '0x' in front

Q: Java: How do you write a numeric literal in octal?
A: With '0' in front.

Q: Java: Is '0' interpreted as 'false' in Java?
A: No.

Q: Java: What are numeric wrapper classes good for?
A: Storing primitives in containers.

Q: Java: What are the 'short circuit' logical operators?
A: && and ||

Q: Java: What arithmetic errors produce runtime exceptions?
A: Only division by zero.

Q: Java: What can go wrong when using >>> on shorts or bytes?
A: The value is promoted to int first.

Q: Java: What can the 'instanceof' operator identify?
A: classes, interfaces and arrays

Q: Java: What does == mean for object references?
A: That they point to the same object

Q: Java: What does == mean for primitive values?
A: that they are equal

Q: Java: What does the equals() method do by default?
A: The same as == does.

Q: Java: What does the operator '>>' do?
A: It shifts bits to the right, preserving the sign bit.

Q: Java: What does the operator '>>>' do?
A: It shifts bits to the right, setting the high-order bit to 0.

Q: Java: What four numeric operators have the highest precedence?
A: increment (++), decrement (--), and unary plus/minus

Q: Java: What happens when shifting an int by 128?
A: Nothing.

Q: Java: What happens when shifting an int by 128?
A: Nothing.

Q: Java: What happens when shifting an int by 129?
A: It's shifted by 1.

Q: Java: What happens when the bitwise negation operator is applied to a byte or a short?
A: The value is converted to an int first.

Q: Java: What is the bitwise and boolean XOR operator?
A: ^

Q: Java: What is the declaration of the 'equals' method?
A: publi
A: boolean equals(Object o);

Q: Java: What is the wrapper class for 'boolean'?
A: Boolean

Q: Java: What is the wrapper class for 'byte'?
A: Byte

Q: Java: What is the wrapper class for 'char'?
A: Character

Q: Java: What is the wrapper class for 'double'?
A: Double

Q: Java: What is the wrapper class for 'float'?
A: Float

Q: Java: What is the wrapper class for 'int'?
A: Integer

Q: Java: What is the wrapper class for 'long'?
A: Long

Q: Java: What is the wrapper class for 'short'?
A: Short

Q: Java: What numeric operators have the lowest priority?
A: assignments: =, += and their ilk

Q: Java: What three numeric operators have priority 2 (just below increment, etc.)?
A: multiplication, division and the modulo operator

Q: Java: What two operators can be used for string concatenation?
A: + and +=

Q: Java: What two operators have precedence 3 (just below multiplication, etc.)?
A: addition and subtraction

Q: Java: What type is assumed by default for floating-point literals?
A: double

Q: Java: What type is assumed by default for integer literals?
A: int

Q: Java: What's the difference between '&' and '&&'?
A: && will short-circuit if the first operand is false.

Q: Java: What's the difference between '|' and '||'?
A: || will short-circuit if the first operand is true.

Q: Java: When are unicode escapes interpreted?
A: As the compiler reads the text, before parsing.

Q: Java: When promoting numeric values, what is the precedence of the various types?
A: double, float, long & int

Q: Java: Which operator performs bitwise negation?
A: ~

Q: Java: Which operator performs logical negation?
A: !

Q: Java: Which right-shift operator preserves the sign bit?
A: >>

Q: Java: Which right-shift operator zero-fills the high-order bit?
A: >>>

Q: Java: Which two numeric wrapper classes AREN'T named after their primitive types?
A: Character & Integer

Q: Java: Are constructors inherited?
A: No.

Q: Java: Are interface fields automatically final?
A: Yes.

Q: Java: Are interface fields automatically public?
A: Yes.

Q: Java: Are interface fields automatically static?
A: Yes.

Q: Java: Are objects immutable when accessed through final references?
A: No.

Q: Java: Can a class be designated 'native'?
A: No.

Q: Java: Can a class be designated 'private'?
A: No.

Q: Java: Can a class be designated 'protected'?
A: No.

Q: Java: Can a class be designated 'public'?
A: Yes.

Q: Java: Can a class implement multiple interfaces?
A: Yes.

Q: Java: Can a class with a private default constructor be subclassed?
A: No.

Q: Java: Can a constructor be declared abstract?
A: No.

Q: Java: Can a constructor be declared final?
A: No.

Q: Java: Can a constructor be declared native?
A: No.

Q: Java: Can a constructor be declared private?
A: Yes.

Q: Java: Can a constructor be declared protected?
A: Yes.

Q: Java: Can a constructor be declared public?
A: Yes.

Q: Java: Can a constructor be declared static?
A: No.

Q: Java: Can a constructor be declared synchronized?
A: No.

Q: Java: Can a constructor be overloaded?
A: Sure.

Q: Java: Can a constructor be overridden?
A: No.

Q: Java: Can a constructor call both super and this?
A: No.

Q: Java: Can a constructor throw exceptions?
A: Yes.

Q: Java: Can a field be declared native?
A: No.

Q: Java: Can a reference point to an interface rather than a class?
A: Yes.

Q: Java: Can a static method access instance variables?
A: No.

Q: Java: Can an abstract class have constructors?
A: Sure.

Q: Java: Can class definitions be found inside the class body?
A: Yes.

Q: Java: Can constructors call each other?
A: Yes.

Q: Java: Can fields be declared abstract?
A: No.

Q: Java: Can interface field values be calculated at runtime?
A: Yes.

Q: Java: Can interface fields have non-constant initializers?
A: Yes.

Q: Java: Can the keyword 'void' be omitted?
A: No.

Q: Java: Can you initialize instance variables in a static initializer?
A: No.

Q: Java: Can you supply an implementation when declaring an abstract method?
A: No.

Q: Java: Constructors must not invoke [...] methods
A: Overridable.

Q: Java: Does Java have 'virtual' methods?
A: Yes: every method is 'virtual'.

Q: Java: Does Java support multiple inheritance?
A: No.

Q: Java: Does reference counting avoid memory leaks?
A: No.

Q: Java: Fields in an interface are automatically [...]
A: public static final.

Q: Java: How can you make a class non-instantiable?
A: Declare a private default constructor.

Q: Java: How do you abort a constructor?
A: Throw an exception.

Q: Java: How do you invoke a parent class's constructor?
A: As if it were a function named 'super'.

Q: Java: How does an interface differ from a class?
A: Its methods must be static abstract, and its fields must be static final.

Q: Java: How does one constructor call another?
A: As if it were a function named 'this'.

Q: Java: How does the compiler handle instance initializer blocks?
A: It copies them into the start of every constructor.

Q: Java: How should constructors be chained?
A: From most general to most specific.

Q: Java: If a field is declared with an initializer, when is the field initialized?
A: Right before the constructor runs.

Q: Java: Is 'virtual' a Java keyword?
A: No.

Q: Java: Is a method's return type part of its signature?
A: No.

Q: Java: May a class have all static members?
A: Sure.

Q: Java: Must a class have instance variables?
A: No.

Q: Java: Must an abstract class have at least one abstract method?
A: No.

Q: Java: Must interface fields be compile-time constants?
A: No.

Q: Java: Must interface fields have constant initializers?
A: No.

Q: Java: Name three GC schemes
A: reference counting, mark-and-sweep, & stop-and-copy.

Q: Java: The opposite of an abstract class is [...]
A: A concrete class OR an own class

Q: Java: What are automatic variables?
A: Variables which are local to a method.

Q: Java: What are class variables?
A: static fields

Q: Java: What are fields?
A: variables in a class

Q: Java: What are static fields called?
A: class variables

Q: Java: What are the problems with reference counting?
A: It's slow, and reference loops cause memory leaks.

Q: Java: What are variable members called?
A: fields

Q: Java: What can be declared 'final'?
A: classes, fields, methods and automatic variables

Q: Java: What can be declared 'native'?
A: Only methods

Q: Java: What can be declared 'public'?
A: Classes, fields and methods.

Q: Java: What can be declared 'static'?
A: Only fields and methods.

Q: Java: What can be declared protected or private?
A: Only class members.

Q: Java: What class modifier can't be used with 'abstract'?
A: final

Q: Java: What class modifier can't be used with 'final'?
A: abstract

Q: Java: What classes can't be instantiated?
A: abstract classes

Q: Java: What classes can't be subclassed?
A: final classes

Q: Java: What does 'final' mean for classes?
A: That they can't be subclassed.

Q: Java: What does 'final' mean for fields?
A: That they can't be changed after they're initialized.

Q: Java: What does 'final' mean for methods?
A: That the method can't be overridden.

Q: Java: What does a compiler-generated default constructor do?
A: Nothing, except call super().

Q: Java: What GC algorithm did old Sun JVMs use?
A: mark-and-sweep

Q: Java: What happens if a constructor doesn't call 'super'?
A: The compiler inserts a call to the default constructor.

Q: Java: What is a method's signature?
A: Its name and argument list.

Q: Java: What is a static initializer for?
A: initializing complicated structures

Q: Java: What is a transient field?
A: one which should be discarded when serializing

Q: Java: What is a volatile field?
A: one which may be modified by multiple threads

Q: Java: What is an 'own class'?
A: A concrete class.

Q: Java: What is another name for a concrete class?
A: an own class

Q: Java: What is the default initialization for reference fields?
A: null

Q: Java: What is the default visibility of class members?
A: Within the same package.

Q: Java: What is the Java equivalent of symbolic constants?
A: static final fields

Q: Java: What is the main problem with mark-and-sweep?
A: The heap becomes fragmented.

Q: Java: What is the return type of a constructor?
A: They don't hava any return type.

Q: Java: What is the scope of an automatic variable?
A: the block in which it is declared

Q: Java: What is the ultimate base class?
A: Object

Q: Java: What is the ultimate base interface?
A: There isn't one.

Q: Java: What kind of class may have abstract methods?
A: abstract classes

Q: Java: What modifier is allowed for automatic variables?
A: final

Q: Java: What restriction applies to static methods?
A: They can only access static fields.

Q: Java: What variables have no default initialization?
A: automatic variables

Q: Java: What's another name for local variables?
A: automatic variables

Q: Java: When are class variables initialized?
A: When the JVM first loads the class.

Q: Java: When are instance variables initialized?
A: When an object is instantiated.

Q: Java: When does one method overload another?
A: When it has the same name but takes different arguments.

Q: Java: When does one method override another?
A: When it has the same signature.

Q: Java: When does the compiler create a default constructor?
A: Only when NO constructors are defined.

Q: Java: When is a static initializer run?
A: When the class is first loaded

Q: Java: When is mark-and-sweep a fast scheme?
A: When very little garbage is being generated.

Q: Java: When must a class be declared abstract?
A: When at least one method is abstract.

Q: Java: When must final object references be initialized?
A: when declared, or in a static initialization block

Q: Java: Where are method definitions found?
A: In the class body.

Q: Java: Where are private members visible?
A: only within the class itself (including nested classes)

Q: Java: Where are protected members visible?
A: Anywhere in the same package, and in subclasses.

Q: Java: Where are public members visible?
A: everywhere

Q: Java: Where can 'super' appear?
A: As the first line of a constructor; nowhere else.

Q: Java: Where can a method's definition appear?
A: It must appear right after the declaration.

Q: Java: Where is i defined?
Q: 
Q: for(int i=0; i<5; i++) {...}
A: between the curly braces

Q: Java: Why might a class have only static members?
A: To group related methods

Q: Java: "An inner class is a nested class that is not explicitly or implicitly [...]."
A: declared static

Q: Java: Anonymous classes are implicitly [...].
A: final

Q: Java: Are any nested classes considered top-level classes?
A: Yes: static nested classes are.

Q: Java: Can a local inner class be declared abstract?
A: No.

Q: Java: Can a local inner class be declared private?
A: No.

Q: Java: Can a local inner class be declared protected?
A: No.

Q: Java: Can a local inner class be declared public?
A: No.

Q: Java: Can an anonymous class be declared abstract?
A: No.

Q: Java: Can an anonymous class be declared static?
A: No.

Q: Java: Can an inner class have a static initializer?
A: No.

Q: Java: Can an interface be nested within another interface?
A: Yes.

Q: Java: Can an interface nested in a class be declared private?
A: Yes.

Q: Java: Can an interface nested in another interface be declared private?
A: No.

Q: Java: Can anonymous constructors throw exceptions?
A: Yes.

Q: Java: Can anonymous inner classes access local variables?
A: Yes, if they are declared final.

Q: Java: Can anonymous inner classes have constructors?
A: No.

Q: Java: Can inner classes have constructors?
A: Yes.

Q: Java: Can inner classes have member interfaces?
A: No.

Q: Java: Can inner classes have the same name as their enclosing class?
A: No.

Q: Java: Can nested classes access private members of the enclosing class?
A: Yes.

Q: Java: Can nested classes have constructors?
A: Yes.

Q: Java: Can you create a (non-static) inner class instance, without creating an instance of the enclosing class?
A: No.

Q: Java: Can you declare a local interface?
A: No.

Q: Java: Can you declare an anonymous interface?
A: No.

Q: Java: Does Java support non-static initialization blocks?
A: Yes.

Q: Java: How can an inner class have non-constant static fields?
A: By inheriting them.

Q: Java: How can you initialize an anonymous class?
A: Use an instance initializer.

Q: Java: How do you define an inner interface?
A: Interfaces are never inner.

Q: Java: How does a nested class instance refer to the enclosing class instance containing it?
A: EnclosingClassName.this

Q: Java: Is there a limit to how deeply classes can be nested?
A: No.

Q: Java: May an inner class have static members?
A: Only if they are compile-time constants.

Q: Java: Must (non-static) inner class instances be associated with an instance of the enclosing class
A: Yes.

Q: Java: Object foo is an instance of Foo. Bar is a non-static inner class of Foo. How do you instantiate a Bar object
A: Foo.Bar bar = Foo.new Bar();

Q: Java: What are instance initialization blocks mostly used for?
A: Initializing anonymous inner classes.

Q: Java: What are the three types of inner class?
A: member, local & anonymous

Q: Java: What are the types of nested interfaces?
A: All nested interfaces are implicitly static.

Q: Java: What can be accessed from a nested static class?
A: Static fields and methods of the enclosing class.

Q: Java: What exceptions do anonymous constructors throw?
A: The ones thrown by any constructors it calls.

Q: Java: What is a nested class (as opposed to an inner class)?
A: A static member class.

Q: Java: What is an inner class?
A: a non-static nested class

Q: Java: What is the scope of a local inner class?
A: The block in which it is defined.

Q: Java: What local variables can be accessed by local inner classes?
A: Any that are declared final.

Q: Java: What rule should you observe when building nested classes?
A: Keep them as tiny as possible.

Q: Java: Where can anonymous inner classes be defined?
A: Anywhere that an object reference may appear.

Q: Java: Where is the body of an anonymous class?
A: Right after the call to the parent's constructor.

Q: Java: Which kinds of nested classes can be accessed from outside the enclosing class?
A: static nested classes and member inner classes

Q: Java: Which nested classes are really top-level classes?
A: Static nested classes.

Q: Java: Are arrays objects?
A: Yes.

Q: Java: Are narrowing conversions allowed?
A: Yes.

Q: Java: Are narrowing conversions ever done implicitly?
A: No.

Q: Java: Can a byte array be cast to an int array?
A: No.

Q: Java: Can a double array be cast to a float array?
A: No.

Q: Java: Can a reference array be cast to a base class array?
A: Yes.

Q: Java: Can a reference array be cast to an array of a derived class?
A: Yes.

Q: Java: Can a short array be cast to a long array?
A: No.

Q: Java: Can an int array be cast to a long array?
A: No.

Q: Java: Can an interface extend multiple base interfaces?
A: Yes.

Q: Java: Can an interface reference be cast to Object?
A: Yes.

Q: Java: Does downcasting require an explicit cast?
A: Yes.

Q: Java: Does instanceof return true for ancestor classes?
A: Yes.

Q: Java: Does upcasting require an explicit cast?
A: No.

Q: Java: How are byte & short values converted to float?
A: They're first converted to int.

Q: Java: How are byte, short & int values converted to double?
A: By first converting them to long.

Q: Java: How are widening integer conversions done?
A: by sign extension

Q: Java: How do you ask whether reference foo points to an object of class bar?
A: if( foo instanceof bar )

Q: Java: How do you test whether objects x and y are of the same type?
A: x.getClass() == y.getClass()

Q: Java: If class foo implements interface bar, can a foo be implicitly cast to a bar?
A: Yes.

Q: Java: If foo extends bar, what does 'instanceof bar' return when called for a foo reference?
A: true

Q: Java: If foo extends bar, what does 'instanceof foo' return when called for a bar reference?
A: false

Q: Java: Is a boolean implicitly converted to another primitive type?
A: No.

Q: Java: Is a null value implicitly converted to a primitive type?
A: No.

Q: Java: Is a primitive value implicitly converted to a boolean?
A: No.

Q: Java: Is a primitive value implicitly converted to an object reference?
A: No.

Q: Java: Is downcasting performed implicitly?
A: Never.

Q: Java: Is upcasting performed implicitly?
A: Yes.

Q: Java: Must a reference array be fully populated before it can be cast?
A: No.

Q: Java: To what can primitive arrays be cast?
A: Object or Cloneable

Q: Java: What does instanceof return when given a null reference?
A: It always returns false.

Q: Java: What exception is thrown when an invalid downcast is attempted?
A: ClassCastException

Q: Java: What happens if an invalid downcast is performed on a reference?
A: A ClassCastException is thrown.

Q: Java: What happens when a huge double is converted to float?
A: It becomes +-infinity.

Q: Java: What happens when a tiny double is converted to float?
A: It becomes 0.

Q: Java: What happens when NaN is converted to a double?
A: It becomes NaN.

Q: Java: What happens when NaN is converted to a float?
A: It becomes NaN

Q: Java: What interface declares the clone method?
A: java.lang.Cloneable

Q: Java: What interfaces do arrays implement?
A: java.io.Serializable and java.lang.Clonable

Q: Java: What interfaces does Object implement?
A: java.io.Serializable and java.lang.Cloneable

Q: Java: What is a 'widening conversion' of a reference?
A: Any conversion to an ancestor class.

Q: Java: What is the fully qualified name of the Cloneable interface?
A: java.lang.Cloneable

Q: Java: What is the fully qualified name of the Serializable interface?
A: java.io.Serializable

Q: Java: What method will tell you the class of object foo?
A: foo.getClass()

Q: Java: What operator is used to check an object's type?
A: instanceof

Q: Java: What type of conversion is Java willing to perform automatically?
A: widening conversions

Q: Java: What type of object conversion will be performed implicitly?
A: upcasting

Q: Java: What's another name for a widening conversion of an object reference?
A: upcasting

Q: Java: When are narrowing conversions performed?
A: When there's an explicit cast.

Q: Java: When is a specific cast needed for object references?
A: When casting to a derived class.

Q: Java: When will Java implicitly convert method arguments?
A: When a widening conversion is called for.

Q: Java: Will code with an illegal downcast compile?
A: Yes.

Q: Java: Will code with an illegal upcast compile?
A: No.

Q: Java: Will Java implicitly convert a char to a short?
A: No.

Q: Java: Are case statements required to have break statements?
A: No.

Q: Java: Are Errors caught?
A: No.

Q: Java: Can label names be reused in a method?
A: Yes.

Q: Java: Can labels have the same names as classes?
A: Yes.

Q: Java: Can labels have the same names as methods?
A: Yes.

Q: Java: Can labels have the same names as variables?
A: Yes.

Q: Java: Can labels stand alone?
A: No, they must be associated with a statement.

Q: Java: Can the initialization part of a for-loop be empty?
A: Yes.

Q: Java: Can the loop condition be empty?
A: Yes.

Q: Java: Can variables be used as the values in case statements?
A: Yes, if they're declared final.

Q: Java: Do case statements without break statements fall through?
A: Yes.

Q: Java: Does a finally clause catch uncaught exceptions?
A: No.

Q: Java: Does Java support goto?
A: No.

Q: Java: How do break and continue work in for-loops?
A: Just as in C.

Q: Java: How do while loops work?
A: Just as in C.

Q: Java: How do you extract a description of a Throwable object?
A: getMessage()

Q: Java: How do you terminate a loop with no loop condition?
A: Use break or throw an exception.

Q: Java: How should catch clauses be ordered?
A: From most specific to least specific.

Q: Java: How should you explicitly forbid invocation of an inherited method?
A: Override and throw an UnsupportedOperationExc...

Q: Java: Is goto a reserved word?
A: Yes, but it's unused.

Q: Java: Is the finally clause executed if an exception is caught?
A: Yes.

Q: Java: Is the finally clause executed if an uncaught exception is thrown?
A: Yes.

Q: Java: Is the finally clause executed if no exception is thrown?
A: Yes.

Q: Java: Must a method throw exceptions, when overriding a method which does?
A: No.

Q: Java: The code is always executed at least once in a [...] loop
A: do-while

Q: Java: The expression in a switch statement must have type [...]
A: char, byte, short or int

Q: Java: The expression in an if statement must have type [...]
A: boolean

Q: Java: The loop condition in a for-loop must have type [...]
A: boolean

Q: Java: What are the two main branches of the Throwable hierarchy ?
A: Error and Exception

Q: Java: What does 'break LABEL' do?
A: Jumps to the line AFTER the label.

Q: Java: What happens if the loop condition is empty?
A: The loop never terminates.

Q: Java: What happens to uncaught exceptions?
A: They're rethrown from the calling method.

Q: Java: What happens to uncaught exceptions listed in the throws clause?
A: They're automatically rethrown.

Q: Java: What happens when a case statement has no break statement?
A: Execution falls through to the next case.

Q: Java: What is a finally block used for?
A: Reclaiming non-memory resources.

Q: Java: What is the ultimate base class of all exceptions and errors?
A: java.lang.Throwable

Q: Java: What's the big thing to watch out for with switch statements?
A: Unexpected fall-throughs.

Q: Java: When is a finally clause executed?
A: ALWAYS.

Q: Java: When is a method 'failure atomic'?
A: When the object is left in its original state if an exception is thrown.

Q: Java: When overriding a method, what exceptions can be thrown?
A: Any thrown by the overridden function, or subclasses thereof.

Q: Java: Which catch clause handles an exception?
A: The first one to whose argument it may be assigned.

Q: Java: Which exceptions are unchecked?
A: Any descendant of RuntimeException.

Q: Java: Are finalizers equivalent to C++ destructors?
A: No!

Q: Java: Are JVM's required to do garbage collection?
A: No.

Q: Java: Are member variables 'virtual'?
A: No.

Q: Java: Can a protected method be overriden by a private method?
A: No.

Q: Java: Can a public method be overriden by a private method?
A: No.

Q: Java: Can a public method be overriden by a protected method?
A: No.

Q: Java: Can an overriding method have a different return type?
A: No.

Q: Java: Can derived classes have methods named after private methods in the parent class?
A: Yes.

Q: Java: Can overloaded methods have different access modifiers?
A: Sure.

Q: Java: Can overloaded methods have different return types?
A: Sure.

Q: Java: Can overloaded methods throw different exceptions?
A: Sure.

Q: Java: Can private methods be overriden?
A: No.

Q: Java: Can static methods be used to implement an interface?
A: No.

Q: Java: Can you protect against subclasses failing to call your finalizer?
A: Yes.

Q: Java: Do the gc() methods force garbage collection to be done?
A: No.

Q: Java: Do trivial finalizers delay memory reclamation?
A: Yes.

Q: Java: Does finalize() have a return value?
A: No.

Q: Java: Does finalize() take any arguments?
A: No.

Q: Java: Does the compiler automatically call super.finalize() inside finalizers?
A: No.

Q: Java: How can local objects be rendered ineligible for garbage collection?
A: By storing them in some structure, or returning them.

Q: Java: How do you call an overridden method?
A: You can't.

Q: Java: How do you call the parent's foo() method from methods in the derived class?
A: super.foo()

Q: Java: How do you force garbage collection to be done?
A: You can't.

Q: Java: How do you release an object for garbage collection?
A: Set any references to it to null.

Q: Java: How is memory compacted using mark-and-sweep?
A: By shuffling objects around.

Q: Java: How is memory compacted using stop-and-copy?
A: By copying live objects back-to-back.

Q: Java: How is the has-a relationship expressed?
A: By composition.

Q: Java: How is the is-a relationship expressed?
A: By subclassing.

Q: Java: How is the JVM's garbage collector run?
A: In a low-priority thread.

Q: Java: How should a finalizer ensure that the parent's finalizer is called?
A: Call it from inside a finally block.

Q: Java: How should an object provide for reclamation of non-memory resources?
A: With an explicit termination method.

Q: Java: If a subclass fails to override an abstract method in the parent class, then [...]
A: it must be declared abstract.

Q: Java: If parent and child have member field foo, which is referred to by childRef.foo?
A: The field in the child.

Q: Java: If parent and child have member field foo, which is referred to by parentRef.foo?
A: The field in the parent.

Q: Java: In what order are objects finalized?
A: No particular order.

Q: Java: Is it legal for two methods to have the same signature but different return types?
A: No.

Q: Java: Is Java immune to memory leaks?
A: No way!

Q: Java: Is runFinalizersOnExit() a bad idea?
A: Yes.

Q: Java: May the finalize method throw exceptions?
A: Yes.

Q: Java: Must a derived class override all abstract methods in the parent?
A: No.

Q: Java: Must a finalizer explicitly call the parent class's finalize() method?
A: Yes.

Q: Java: Must an overriding method have the same return type?
A: Yes.

Q: Java: Should files be closed in finalizers?
A: No.

Q: Java: What does Runtime.getRuntime.gc() do?
A: It suggests that garbage collection be done.

Q: Java: What does String.intern() do?
A: It searches already-existing strings for a match.

Q: Java: What does System.gc() do?
A: It suggests that garbage collection be done.

Q: Java: What does the JVM do if a finalizer throws an exception?
A: It aborts finalization but otherwise ignores it.

Q: Java: What exception is thrown when an object is invoked after, e.g., closing its files?
A: IllegalStateException

Q: Java: What is 'unintentional object retention'?
A: Failure to clear obsolete references.

Q: Java: What is a finalizer guardian?
A: A member object which does the actual finalization.

Q: Java: What is an overridable method?
A: A non-final method which is public or protected.

Q: Java: What is polymorphism?
A: The fact that an object can have different identities

Q: Java: What is RTTI?
A: Run-Time Type Identification.

Q: Java: What is the best way to discard obsolete references?
A: Let them pass out of scope.

Q: Java: What is the canonical example of an object that should be pooled?
A: Database connections.

Q: Java: What is the default GC algorithm?
A: stop-and-copy.

Q: Java: What is the second best way to discard obsolete references?
A: Assign them to something else.

Q: Java: What is the signature of Object.finalize()?
A: protected void finalize()

Q: Java: What is the usual way for a method to reclaim its non-memory resources?
A: In a finally block.

Q: Java: What is the worst way to discard obsolete references?
A: Assigning them to null.

Q: Java: What kinds of objects are likeliest to cause memory leaks?
A: Containers and caches.

Q: Java: What method guarantees that finalizers will be run?
A: System.runFinalizersOnExit()

Q: Java: What method performs cleanup before garbage collection?
A: finalize()

Q: Java: What tool can help track down memory leaks?
A: A heap profiler.

Q: Java: When are field references resolved?
A: At compile time.

Q: Java: When can an object be garbage collected?
A: When no references point to it.

Q: Java: When do local objects become eligible for garbage collection?
A: When they go out of scope.

Q: Java: When is an object pool justified?
A: For extremely heavyweight objects.

Q: Java: When is stop-and-copy the fastest GC algorithm?
A: When there are lots of short-lived little objects.

Q: Java: Why is runFinalizersOnExit() deprecated?
A: It may cause finalizers to run for still-active objects.

Q: Java: Why is the current GC algorithm called 'adaptive'?
A: Because it switches between mark-and-sweep and stop-and-copy.

Q: Java: Always calling notifyAll() avoids what security problem
A: Malicious wait() calls from an unrelated thread.

Q: Java: Are locks released when synchronized code throws an exception?
A: Yes.

Q: Java: Are locks released when the thread holding them is suspended?
A: No.

Q: Java: Can a dead thread be restarted?
A: No.

Q: Java: Can a user thread be converted to a daemon thread after it's been started?
A: No.

Q: Java: Can an application create daemon threads?
A: Yes.

Q: Java: Can static methods be synchronized?
A: Yes.

Q: Java: Can you prevent a thread from blocking forever when calling join()?
A: Yes: supply a millisecond timeout.

Q: Java: Can you prevent a thread from blocking forever when calling wait()?
A: Yes: supply a millisecond timeout.

Q: Java: Can you synchronize on a local object?
A: Yes.

Q: Java: Does every object have a synchronization lock?
A: Yes.

Q: Java: Every time wait() returns, you should [...]
A: Check the postcondition.

Q: Java: How can a thread wake up everyone on the wait list?
A: notifyAll()

Q: Java: How can you reduce synchronization overhead for rare behaviors?
A: Use double-checked locking.

Q: Java: How do you create a daemon thread?
A: Call its setDaemon() method before calling start().

Q: Java: How do you start a thread?
A: Call its start() method.

Q: Java: How should you check whether a thread has been interrupted?
A: Call Thread.isInterrupted().

Q: Java: If a method overrides a synchronized method, is it automatically synchronized?
A: No.

Q: Java: If class Foo implements Runnable, how would you attach a Foo object to a thread?
A: new Thread(new Foo() )

Q: Java: Is a different thread guaranteed to be run when one thread calls yield()?
A: No.

Q: Java: Is Thread.interrupted() an instance method or a static method?
A: A static method.

Q: Java: Is Thread.isInterrupted() an instance method or a static method?
A: An instance method.

Q: Java: Synchronized code should never call [...] methods.
A: Overridable.

Q: Java: What are the two types of threads?
A: User and daemon.

Q: Java: What are the two ways to get work done in a thread?
A: Subclass Thread, or implement Runnable.

Q: Java: What can be synchronized?
A: Methods or code blocks.

Q: Java: What constant gives the least urgent thread priority?
A: Thread.MIN_PRIORITY

Q: Java: What constant gives the most urgent thread priority?
A: Thread.MAX_PRIORITY

Q: Java: What exception can be thrown by Thread.sleep()?
A: InterruptedException

Q: Java: What four states may a thread occupy?
A: New, Runnable, Blocked & Dead

Q: Java: What happens if wait() or notify() is called outside synchronized code?
A: An IllegalMonitorStateException is thrown.

Q: Java: What happens when a thread calls another thread's join() method?
A: It waits for that thread to die.

Q: Java: What happens when start() is called on a running thread?
A: IllegalThreadStateException is thrown.

Q: Java: What is the declaration of the run() method?
A: public void run()

Q: Java: What is the deprecated way to kill a thread?
A: Thread.stop()

Q: Java: What is the least urgent thread priority?
A: 1 or Thread.MIN_PRIORITY

Q: Java: What is the most urgent thread priority?
A: 10

Q: Java: What is the range of thread priorities?
A: 1 through 10

Q: Java: What is the signature of the high-resolution sleep() method?
A: Thread.sleep( long ms, int ns )

Q: Java: What is the signature of the normal sleep() method?
A: Thread.sleep( long ms )

Q: Java: What is the syntax for synchronizing a block of code?
A: synchronized (ref)
A: // cod
A: }

Q: Java: What is the value of Thread.MAX_PRIORITY?
A: 10

Q: Java: What is the value of Thread.MIN_PRIORITY?
A: 1

Q: Java: What is the value of Thread.NORM_PRIORITY?
A: 5

Q: Java: What method can be used to interrupt a sleeping or waiting thread?
A: interrupt()

Q: Java: What method is used to change the priority of a thread?
A: setPriority

Q: Java: What moves a thread from the new state to the runnable state?
A: Calling its start() method.

Q: Java: What must a class do to implement the Runnable interface?
A: It must provide a run() method.

Q: Java: What object is locked by a synchronized method?
A: this

Q: Java: What priority is assigned to new threads by default?
A: The priority of the parent thread.

Q: Java: What Thread methods must be called inside try block?
A: sleep, join & wait

Q: Java: When does a JVM shut down?
A: When all running threads are daemon threads.

Q: Java: When does a thread die?
A: When its run() method exits.

Q: Java: Where must wait() and notify() be called?
A: From within synchronized code.

Q: Java: Which common Thread methods are static?
A: sleep() & yield()

Q: Java: Which Thread methods can only be called from within synchronized code?
A: wait, notify & notifyAll

Q: Java: Which Thread methods have an optional timeout?
A: join & wait

Q: Java: Who goes to sleep when Thread.sleep() ls called?
A: The thread from which it was called.

Q: Java: Who is responsible for preventing deadlocks?
A: The programmer.

Q: Java: Who is waked up when notify() is called?
A: A random member of the wait list.

Q: Java: Why is resume() deprecated?
A: Because suspend() is.

Q: Java: Why is stop() deprecated?
A: It's just too dangerous.

Q: Java: Why is suspend() deprecated?
A: Because it can cause deadlock.

Q: Java: Why is Thread.interrupted() dangerous?
A: Because it clears the interrupted flag.

Q: Java: Why is yield() good for portability?
A: Because different JVMs can use different schedulers.

Q: Java: Always override [...] if you override equals()
A: hashCode()

Q: Java: Are classes in the Collections API synchronized by default?
A: No.

Q: Java: ArrayList corresponds roughly to the [...] class in Java 1.1
A: Vector

Q: Java: ArrayList extends [...]
A: AbstractList.

Q: Java: Can a Comparable compare itself to objects of another class?
A: No.

Q: Java: Can a Comparator compare objects of different classes?
A: Sure.

Q: Java: Contents of a SortedMap are sorted by [...]
A: The keys.

Q: Java: Does Arrays.asList( foo ) create a copy of foo?
A: No.

Q: Java: Does Map inherit from Collection?
A: No.

Q: Java: Does System.arraycopy() do a shallow or deep copy?
A: A shallow copy.

Q: Java: Give the declarations of readExternal and writeExternal
A: public void readExternal( ObjectInput s )
A: public void writeExternal( ObjectOutput s );

Q: Java: HashMap corresponds roughly to the [...] class in Java 1.1
A: HashTable.

Q: Java: How can you check whether a given key is stored in a Hashtable?
A: Use the containsKey() method.

Q: Java: How can you check whether a given value is stored in a Hashtable?
A: Use the contains() method.

Q: Java: How can you exit with status S?
A: System.exit(S)

Q: Java: How can you find out the number of elements in a collection?
A: With the size() method.

Q: Java: How can you get a reference to the singleton Runtime instance?
A: Runtime.getRuntime()

Q: Java: How can you test whether a character is a number?
A: Character.isDigit()

Q: Java: How can you test whether a character is alphabetic?
A: Character.isLetter()

Q: Java: How do you check whether a collection contains anything at all?
A: With the isEmpty() method.

Q: Java: How do you determine the size of an ArrayList?
A: With the size() method.

Q: Java: How were the original Java collections modified in SDK 1.2?
A: They started implementing the Collections API.

Q: Java: How would you create an iterator for Collection foo?
A: Call foo.iterator().

Q: Java: If possible, compareTo() should be consistent with [...]
A: equals()

Q: Java: Is compareTo() allowed to throw a ClassCastException?
A: Yes.

Q: Java: Is compareTo() allowed to throw a NullPointerException?
A: Yes.

Q: Java: Is there any way to randomly access the elements in a collection?
A: No.

Q: Java: Iterator is supposed to supplant what interface
A: Enumeration.

Q: Java: Must you use an iterator to retrieve the elements of a collection?
A: Yes.

Q: Java: Should equals() ever throw a NullPointerException?
A: No.

Q: Java: Should you always override toString()?
A: Yes.

Q: Java: The Collections API is found in what package
A: java.util.

Q: Java: The core of the Collections API is a set of [how many] interfaces
A: Six interfaces.

Q: Java: The interface [...] is the root of the Collections API hierarchy
A: Collection.

Q: Java: The three most basic Collections API interfaces are
A: Set, List & Map.

Q: Java: Two Collections API interfaces require that objects be kept sorted: [...]
A: SortedSet and SortedMap.

Q: Java: Vector corresponds roughly to [...] in the Collections API
A: ArrayList.

Q: Java: What are the main methods for the ArrayList class?
A: add() & get().

Q: Java: What are the two categories of container?
A: Collections and Maps.

Q: Java: What are the two main Hashtable methods?
A: get() and put().

Q: Java: What are the two main methods for accessing a Stack?
A: push() and pop().

Q: Java: What class defines standard math functions?
A: java.lang.Math.

Q: Java: What class lets you manipulate strings efficiently?
A: StringBuffer.

Q: Java: What class provides methods for array manipulation?
A: java.util.Arrays.

Q: Java: What classes are used to serialize an object?
A: ObjectInputStream & ObjectOutputStream.

Q: Java: What classes depend critically on the equals() contract?
A: Collection classes.

Q: Java: What classes provide arbitrary-precision arithmetic?
A: BigDecimal & BigInteger.

Q: Java: What Collections interface does Hashtable implement?
A: Map.

Q: Java: What constant gives the largest possible byte value?
A: Byte.MAX_VALUE

Q: Java: What constant gives the largest possible integer value?
A: Integer.MAX_VALUE

Q: Java: What constant gives the largest possible long value?
A: Long.MAX_VALUE

Q: Java: What constant gives the largest possible short value?
A: Short.MAX_VALUE

Q: Java: What constant gives the smallest possible byte value?
A: Byte.MIN_VALUE

Q: Java: What constant gives the smallest possible integer value?
A: Integer.MIN_VALUE

Q: Java: What constant gives the smallest possible long value?
A: Long.MIN_VALUE

Q: Java: What constant gives the smallest possible short value?
A: Short.MIN_VALUE

Q: Java: What does a Hashtable do with duplicate keys?
A: Throws away the old one.

Q: Java: What does Double.MIN_VALUE tell you?
A: The smallest positive double value.

Q: Java: What does Float.MIN_VALUE tell you?
A: The smallest positive float value.

Q: Java: What does Iterator have that Enumeration does not?
A: A remove() method.

Q: Java: What Enumeration method corresponds to the Iterator method hasNext()?
A: hasMoreElements()

Q: Java: What Enumeration method corresponds to the Iterator method next()?
A: nextElement().

Q: Java: What interface gives better performance than Serializable?
A: Externalizable

Q: Java: What interface is supposed to supplant Enumeration?
A: Iterator.

Q: Java: What interface must be implemented in order for a class to be serializable?
A: java.io.Serializable.

Q: Java: What is a Comparator actually for?
A: Providing a 'function pointer' to hand in to sorting algorithms.

Q: Java: What is BigInteger mostly used for?
A: Cryptography.

Q: Java: What is the Comparable interface for?
A: Imposing a natural order on a type.

Q: Java: What is the contract of the equals method?
A: It must define an equivalence relation, in which null is its own equivalence class.

Q: Java: What is the difference between Comparable and Comparator?
A: Comparable defines a natural ordering on a class; Comparator provides an external sort mechanism.

Q: Java: What is the equals-hashCode contract?
A: Two equal objects must return the same hashCode.

Q: Java: What is the return type of Integer.parseInt()?
A: int.

Q: Java: What is the return type of Integer.valueOf()?
A: Integer.

Q: Java: What Iterator method corresponds to the Enumeration method hasMoreElements()?
A: hasNext().

Q: Java: What Iterator method corresponds to the Enumeration method nextElement()?
A: next().

Q: Java: What method converts a Boolean to a boolean?
A: booleanValue()

Q: Java: What method converts a string to an int?
A: Integer.parseInt()

Q: Java: What method performs a fast native copy of arrays?
A: System.arraycopy()

Q: Java: What method returns a millisecond timestamp?
A: System.currentTimeMillis()

Q: Java: What method tests whether an Enumeration has any elements after the current one?
A: hasMoreElements().

Q: Java: What methods are required to implement Externalizable?
A: readExternal and writeExternal.

Q: Java: What must a class provide to implement Comparator?
A: A two-argument compare() method.

Q: Java: What must you do to implement the Comparable interface?
A: Suppy a compareTo() method.

Q: Java: What objects correspond to stdin, stdout & stderr?
A: System.in, System.out & System.err.

Q: Java: What original collection implements a dynamically growing array?
A: Vector.

Q: Java: What original collection stores name/value pairs?
A: Hashtable.

Q: Java: What package provides BigDecimal & BigInteger?
A: java.math.

Q: Java: What package provides the reflection API?
A: java.lang.reflect.

Q: Java: What performance hit can result from calling setLength(0) on a StringBuffer?
A: It can trigger a copy of the (possibly large) underlying array.

Q: Java: What should you do if x.compareTo(y) and y.compareTo(x) are both 0, but y.equals(x) is false?
A: Document that compareTo() is inconsistent with equals().

Q: Java: What two things depend critically on the reflection API?
A: JavaBeans & serialization.

Q: Java: What type are the arguments to java.lang.Math trig functions?
A: double.

Q: Java: What types are allowed as Hashtable keys?
A: Any Object.

Q: Java: What was the main problem with pre-Java 2 collection classes?
A: They were highly synchronized, & so incurred a performance penalty.

Q: Java: When must you use the fully-qualified class name for List?
A: When importing both java.util.* & java.awt.*.

Q: Java: When was the Collections API introduced?
A: With Java SDK 1.2.

Q: Java: Which interface is part of the Collections API: Iterator or Enumeration?
A: Iterator.

Q: Java: Which interface predates the Collections API: Iterator or Enumeration?
A: Enumeration.

Q: Java: Which is a singleton: System or Runtime?
A: Runtime.

Q: Java: Which is an all-static class: System or Runtime?
A: System.

Q: Java: Why is it good to group multiple String + operators in one statement?
A: The compiler will optimize them into calls to StringBuffer.append().

Q: Java: Why should you implement Externalizable rather than Serializable?
A: Performance.

Q: Java: Will a Hashtable store multiple values per key?
A: No.

Q: Java: [...] bundles a bunch of utility functions for the Collections API
A: The Collections class.

Q: Java: A 'peer' is [...]
A: An OS object backing an AWT component.

Q: Java: Almost all display classes are based on [...]
A: Component.

Q: Java: AWT components are heavyweight because [...]
A: They're backed by OS peers.

Q: Java: Can a component ignore events?
A: Yes.

Q: Java: Do Swing classes extend Component?
A: Yes.

Q: Java: How can you check whether a given point is within a given Component?
A: Use the contains() method.

Q: Java: How can you specify the cursor image when the mouse passes over a component?
A: Use the setCursor() method.

Q: Java: How do you set the default font?
A: The Component setFont() method.

Q: Java: If you need to manipulate a screen object, the first place to look is at [...]
A: Component methods.

Q: Java: Must a component handle every type of event?
A: No.

Q: Java: Position (0,0) always means
A: The upper left-hand corner of the container.

Q: Java: Position is always relative to [...]
A: The upper left-hand corner of the immediate container.

Q: Java: Screen positions are always measured in [...]
A: Pixels.

Q: Java: setBounds can take a Rectangle argument or [...]
A: Four integers: x, y, width & height.

Q: Java: setLocation can take a Point argument, or [...]
A: Two integers, x & y.

Q: Java: setSize() can take a Dimension object or [...] as arguments
A: Two integers, width & height.

Q: Java: The contains() method belongs to what class
A: Component.

Q: Java: The contains() method can take a Point argument or [...]
A: Two integers: x & y.

Q: Java: What argument type do setForeground() and setBackground() take?
A: Color.

Q: Java: What arguments do enableEvents() and disableEvents() take?
A: long.

Q: Java: What class defines event mask constants?
A: AWTEvent.

Q: Java: What classes are found in java.awt?
A: The original AWT classes.

Q: Java: What Component method sets the background color?
A: setBackground().

Q: Java: What Component method sets the foreground color?
A: setForeground().

Q: Java: What Component methods enable and disable various events?
A: enableEvents() & disableEvents().

Q: Java: What Component methods get or set the size?
A: getSize() & setSize().

Q: Java: What does AWT stand for?
A: Abstract Windowing Toolkit.

Q: Java: What does java.awt.datatransfer provide?
A: Support for cut-and-paste operations.

Q: Java: What does java.awt.dnd provide?
A: Drag-and-drop support.

Q: Java: What does java.awt.event provide?
A: Support for GUI event handling.

Q: Java: What does java.awt.font provide?
A: Support for text rendering.

Q: Java: What does java.awt.geom provide?
A: Support for 2D drawing.

Q: Java: What does java.awt.im provide?
A: Support for user input.

Q: Java: What does java.awt.image provide?
A: Support for image manipulation.

Q: Java: What does java.awt.image.renderable provide?
A: Interfaces to assist with image rendering.

Q: Java: What does java.awt.print provide?
A: Printing support.

Q: Java: What does setBounds() do?
A: The same as setLocation() & setSize() put together.

Q: Java: What is the meaning of the long argument to enableEvents() and disableEvents()?
A: A bitmask.

Q: Java: What is the return type of getLocation()?
A: Point.

Q: Java: What is the return type of getSize()?
A: Dimension.

Q: Java: What method enables and disables a component?
A: setEnabled().

Q: Java: What method replaces show() from Java 1?
A: setVisible().

Q: Java: What methods get or set the position of a component?
A: getLocation() & setLocation().

Q: Java: What objects can help you specify position and size?
A: Point, Dimension & Rectangle.

Q: Java: What package contains classes for working with colors?
A: java.awt.color.

Q: Java: What package contains the original AWT classes?
A: java.awt.

Q: Java: What package provides printing support?
A: java.awt.print.

Q: Java: What package provides support for user input?
A: java.awt.im.

Q: Java: What package provides text rendering support?
A: java.awt.font.

Q: Java: What package supports 2D drawing?
A: java.awt.geom.

Q: Java: What package supports cut-and-paste operations?
A: java.awt.datatransfer.

Q: Java: What package supports drag-and-drop?
A: java.awt.dnd.

Q: Java: What package supports GUI event handling?
A: java.awt.event.

Q: Java: What package supports image manipulation?
A: java.awt.image.

Q: Java: What package would you look up to find out about GUI events?
A: java.awt.event.

Q: Java: What three methods can be used to query the max, min & preferred Component sizes?
A: getMaximumSize(), getMinimumSize() & getPrefferedSize().

Q: Java: Which package provides enhanced image rendering support?
A: java.awt.image.renderable.

Q: Java: Can a File object point to a directory?
A: Yes.

Q: Java: How can you tell whether a File object points to a file or a directory?
A: isFile() and isDirectory().

Q: Java: How is complex stream processing done?
A: By chaining stream objects.

Q: Java: Must a File object point to an existing file or directory?
A: No.

Q: Java: What class has methods for listing a directory?
A: File.

Q: Java: What class is System.out?
A: PrintStream.

Q: Java: What class supports non-sequential I/O?
A: RandomAccessFile.

Q: Java: What classes support locale-specific character conversions?
A: Reader and Writer.

Q: Java: What exception is thrown if an applet tries to access the filesystem?
A: SecurityException

Q: Java: What File method lists files in a directory as Files?
A: listFiles().

Q: Java: What File method lists files in a directory as Strings?
A: list().

Q: Java: What File method will create a file in the filesystem?
A: createNewFile()

Q: Java: What is the main class for interacting with the filesystem?
A: File.

Q: Java: What is the type of File.separator and File.pathSeparator?
A: String.

Q: Java: What is the value of File.pathSeparator on UNIX?
A: A colon (:)

Q: Java: What is the value of File.pathSeparator on Windows?
A: A semicolon (;)

Q: Java: What is the value of File.separator on UNIX?
A: A forward slash (/)

Q: Java: What is the value of File.separator on Windows?
A: A backslash (\)

Q: Java: What packages support reading and writing data in jar files?
A: java.util.zip & java.util.jar.

Q: Java: What should you use instead of PrintStream?
A: PrintWriter.

Q: Java: What types support reading and writing Java primitives?
A: DataInput and DataOutput.

Q: Java: When does creation of a File object modify the filesystem?
A: Never.

Q: Java: Can methods be inlined in Java??
A: Yes--but only final methods.

Q: Java: What are the values of i & x?
Q: 
Q: int   i = 6
Q: int x = ++i + i++ % 5
A: i = 8, x = 9.

Q: Java: What is the data type of the expression?
Q: 
Q: (byte) 1 + 1
A: int

Q: Java: What is the data type of the expression?
Q: 
Q: 1 + (short) 1
A: int

Q: Java: What is the data type of the expression?
Q: 
Q: 1 + 1L
A: long

Q: Java: What is the data type of the expression?
Q: 
Q: 1.1 + 1
A: double

Q: Java: What is the data type of the expression?
Q: 
Q: 1F + (short) 1
A: float

Q: Java: What is the data type of the expression?
Q: 
Q: 1F + 1.1
A: double

Q: Java: What is the data type of the expression?
Q: 
Q: 1F + 1L
A: float

Q: Java: What is the data type of the expression?
Q: 
Q: 1L + 1.0
A: double

Q: Java: What is the value of x?
Q: 
Q: int   i = 3
Q: int x = i++;
A: 3

Q: Java: What is the value of x?
Q: 
Q: int i   = 3
Q: int x = ++i;
A: 4

Q: Java: What is the value of x?
Q: 
Q: int x = 3 * 2 + 7 % 5
A: 8

Q: Java: Will this work?
Q: void swap(Object a, Object b)
Q: Object tmp = a
Q: a = b
Q: b = tmp
Q: }
A: No.

Q: Java: Will This Compile?
Q: abstract final class foo
Q: ..
Q: }
A: No.

Q: Java: Will This Compile?
Q: byte b = 10
Q: switch (b)
Q: case 127: break
Q: default: foo()
Q: }
A: Yes.

Q: Java: Will This Compile?
Q: byte b = 10
Q: switch (b)
Q: case 128: break
Q: default: foo()
Q: }
A: No.

Q: Java: Will This Compile?
Q: char c = "A";
A: No.

Q: Java: Will This Compile?
Q: char c = 'A'
A: No.

Q: Java: Will This Compile?
Q: class foo
Q: class bar
Q: final int k
Q: ..
Q: 
Q: }
A: Yes.

Q: Java: Will This Compile?
Q: class foo
Q: class bar
Q: static final int k = 0
Q: ..
Q: 
Q: }
A: Yes.

Q: Java: Will This Compile?
Q: class foo
Q: class bar
Q: static final int k
Q: ..
Q: 
Q: }
A: No.

Q: Java: Will This Compile?
Q: class foo
Q: class bar
Q: static int k = 9
Q: ..
Q: 
Q: }
A: No.

Q: Java: Will This Compile?
Q: class foo
Q: static class bar
Q: static final int k
Q: ..
Q: 
Q: }
A: Yes.

Q: Java: Will This Compile?
Q: double f = 3.1415;
A: Yes.

Q: Java: Will This Compile?
Q: float f = 4
Q: byte b = f;
A: No.

Q: Java: Will This Compile?
Q: for (i=0, j=0;;);
A: Yes.

Q: Java: Will This Compile?
Q: for (int i=0, int j=0;;);
A: No.

Q: Java: Will This Compile?
Q: int a = 1
Q: if (a == 1) foo();
A: Yes.

Q: Java: Will This Compile?
Q: int a = 1
Q: if (a) foo();
A: No.

Q: Java: Will This Compile?
Q: int a = 1L;
A: No.

Q: Java: Will This Compile?
Q: int foo()
Q: final a = 99
Q: class ba
Q: {void s() {int b=a;};
Q: ..
Q: }
A: No.

Q: Java: Will This Compile?
Q: int foo()
Q: final int a = 5
Q: class bar {void s() {a++;};
Q: ..
Q: }
A: No.

Q: Java: Will This Compile?
Q: int foo()
Q: final int a = 9
Q: class ba
Q: {void s() {int b=a;};
Q: ..
Q: }
A: No.

Q: Java: Will This Compile?
Q: int foo()
Q: final int a = 99
Q: class ba
Q: {void s() {int b=a;};
Q: ..
Q: }
A: Yes.

Q: Java: Will This Compile?
Q: int foo()
Q: final int a
Q: class bar {void s() {a++;};
Q: ..
Q: }
A: No.

Q: Java: Will This Compile?
Q: int foo()
Q: int a = 6
Q: class bar {void s() {a++;};
Q: ..
Q: }
A: No.

Q: Java: Will This Compile?
Q: int foo()
Q: int a
Q: class bar {void s() {a++;};
Q: ..
Q: }
A: No.

Q: Java: Will This Compile?
Q: int foo()
Q: static final int a = 99
Q: class ba
Q: {void s() {int b=a;};
Q: ..
Q: }
A: No.

Q: Java: Will This Compile?
Q: int[8] foo;
A: No.

Q: Java: Will This Compile?
Q: short i = 32768;
A: No.

Q: Java: Will This Compile?
Q: short s = 10
Q: switch (s)
Q: case 32767: break
Q: default: foo()
Q: }
A: Yes.

Q: Java: Will This Compile?
Q: short s = 10
Q: switch (s)
Q: case 32768: break
Q: default: foo()
Q: }
A: No.

Q: Java: Will This Compile?
Q: short s = 1
Q: s += 1;
A: Yes.

Q: Java: Will This Compile?
Q: short s = 1
Q: s = s + 1;
A: No.

Q: Java: Will This Compile?
Q: String foo()
Q: String s = null
Q: return s
Q: }
A: Sure.

Q: Java: Will This Compile?
Q: synchronized void foo()
Q: try { wait();
Q: catch (Throwable) {
Q: }
A: Yes.

Q: Java: Will This Compile?
Q: synchronized void foo()
Q: wait()
Q: }
A: No.

Q: Java: Will This Compile?
Q: try { int k = 1; foo(k);
Q: catch(bar b) {...
Q: k++;
A: No.

Q: Java: Will This Compile?
Q: try {...
Q: catch ( Object obj ) {...}
A: No.

Q: Java: Will This Compile?
Q: void doNothing()
Q: return
Q: doSomething()
Q: }
A: No.

Q: Java: Will This Compile?
Q: void foo()
Q: notify()
Q: }
A: Yes.

Q: Java: Will This Compile?
Q: void foo()
Q: try { wait();
Q: catch (Throwable t) {
Q: }
A: Yes.

Q: Java: Will This Compile?
Q: void foo()
Q: wait()
Q: }
A: No.

Q: Java: Will This Compile?
Q: void foo()
Q: int a
Q: if (a == 2) bar()
Q: }
A: No.

Q: Java: How do @see doc tags appear in Javadoc output?
A: As hyperlinks in a 'see also' section.

Q: Java: Is HTML the only choice of output format?
A: No; you can use doclets to support other document formats.

Q: Java: What are doclets for?
A: Supporting output formats other than HTML.

Q: Java: What can Javadoc comments describe?
A: Classes, fields & methods.

Q: Java: What class members are documented by default?
A: Only public & protected members.

Q: Java: What do you use to support output formats other than HTML?
A: Doclets.

Q: Java: What doc tag can be used to make inline cross-references?
A: @link.

Q: Java: What doc tag is normally used for cross-references?
A: @see

Q: Java: What doc tag is used to describe exceptions that might be thrown?
A: @throws

Q: Java: What doc tag is used to describe method arguments?
A: @param

Q: Java: What doc tag is used to describe method return values?
A: @return

Q: Java: What doc tag is used to flag deprecated methods?
A: @deprecated

Q: Java: What doc tags can be used for classes?
A: @version, @author and @since

Q: Java: What does @link do?
A: Creates an inline cross-reference.

Q: Java: What HTML tags should NOT be used in Javadoc comments?
A: headings and hr.

Q: Java: What is ignored at the beginning of a line?
A: Whitespace & asterisks.

Q: Java: What is the @since tag used for?
A: Indicating the version which introduced a feature.

Q: Java: What is the default format for Javadoc output?
A: HTML.

Q: Java: What type of markup is allowed in Javadoc comments?
A: HTML and 'doc tags'.

Q: Java: Where must doc tags appear?
A: At the beginning of a line.

Q: Java: How is a macro used in an XML build file?
A: ${macro-name}

Q: Java: What <copy> attribute specifies the destination of the copy?
A: todir=

Q: Java: What <target> attribute lists dependencies?
A: depends=

Q: Java: What are the most important attributes of a property element?
A: name & value

Q: Java: What element defines 'variables' in an ant build file?
A: <property>

Q: Java: What element is used to specify build targets?
A: <target>

Q: Java: What element specifies the action of copying files?
A: <copy>

Q: Java: What element specifies the action of creating a directory?
A: <mkdir>

Q: Java: What element specifies the action of running the java compiler?
A: <javac>

Q: Java: What element specifies the deletion of files or directories?
A: <delete>

Q: Java: According to Tim Ritchey's book, what two words are no longer reserved
A: threadsafe & byvalue.

Q: Java: Can the classpath be used to override a class in the extension folder?
A: No.

Q: Java: How can you override the default extension folder?
A: Set the java.ext.dirs system property at run time.

Q: Java: How did the Java package structure change from the earliest releases?
A: The prefix java. was added.

Q: Java: How do you use the extension mechanism?
A: Dump your jar files in the extension folder.

Q: Java: In what year did Gosling start work on Oak?
A: 1991

Q: Java: In what year were Java and HotJava unveiled?
A: 1995.

Q: Java: Is the classpath searched before or after the extension folder?
A: After.

Q: Java: What (no longer) reserved word was intended to support operator overloading?
A: operator.

Q: Java: What (no longer) reserved word was intended to support templates?
A: generic

Q: Java: What is the default folder for extensions?
A: $JAVA_HOME/jre/lib/ext

Q: Java: What language introduced dynamic binding?
A: SIMULA.

Q: Java: What language was most infuential on Gosling when he designed Java?
A: SIMULA.

Q: Java: What mechanism replaces classpath for Java2?
A: The extension mechanism.

Q: Java: What two jarfiles contain Java's bootstrap classes?
A: rt.jar & il8n.jar.

Q: Java: What was HotJava originally called?
A: WebRunner.

Q: Java: What was my first Java distribution?
A: HotJava alpha 3 for Solaris.

Q: Java: What was SIMULA originally used for?
A: Monte Carlo simulations.

Q: Java: When did awt become java.awt?
A: In late 1995, when the beta was released.

Q: Java: When did blackdown first appear?
A: Late in 1995.

Q: Java: When was Randy Chapman's Linux JDK released?
A: Late in 1995.

Q: Java: When was the first JVM for VMS released?
A: Late in 1997.

Q: Java: When was WebRunner (AKA HotJava) written?
A: September of 1994.

Q: Java: Where are Java's internationalization classes found?
A: il8n.jar.

Q: Java: Where are the Java runtime classes found?
A: rt.jar.

Q: Java: Where did I download my first Java realease from?
A: Sunsite.

Q: Java: Which is searched first, the extension folder or the classpath?
A: The extension folder.

Q: Java: Which is searched last, the extension folder or the classpath?
A: The classpath.

Q: Java: Who first ported the JDK to Linux?
A: Randy Chapman.

Q: Java: Will a class in the extension folder override a class of the same name on the classpath?
A: Yes.

Q: Java: Does the SDK include a debugger?
A: Yes: jdb.

Q: Java: How can you get profiling data on a Java app?
A: Run java with the -Xprof option.

Q: Java: How can you log GC activity to FILE?
A: Run java with the option -Xloggc:FILE

Q: Java: How do you enable remote debugging of a Java app?
A: Run java with the -Xdebug option.

Q: Java: To use jdb, how must you compile your Java code?
A: With the -g option.

Q: Java: What does a ClassFormatError mean?
A: A class file was somehow unreadable.

Q: Java: What does JVMPI stand for?
A: JVM Profiling Interface.

Q: Java: What free Java tool gives a graphical display of profiling data?
A: HPjmeter.

Q: Java: What is the standard debugger called?
A: jdb.

Q: Java: What should you try when your app aborts with a ClassFormatError?
A: Try recompiling the offending class.

Q: Java: Is the ejb-jar.xml file mandatory?
A: Yes.

Q: Java: Is the ejb-jar.xml file specific to JBoss?
A: No--it's part of the standard.

Q: Java: What is an EJB deployment descriptor?
A: The file ejb-jar.xml.

Q: Java: What is the 'Foo' in FooBean called?
A: The simple name.

Q: Java: What is the base class for EJB home interfaces?
A: EJBHome.

Q: Java: What is the base class for EJB remote interfaces?
A: EJBObject.

Q: Java: What methods should a remote interface have?
A: One for each public method in the bean class.

Q: Java: What name is given to an EJB's home interface?
A: The bean's simple name with 'Home' appended.

Q: Java: What name is given to an EJB's remote interface?
A: The bean's simple name.

Q: Java: What three classes would you define to create an EJB called Foo?
A: Foo, FooBean & FooHome.

Q: Java: What three things make up an EJB?
A: A bean class, a remote interface, and a home interface.

Q: Java: What would you name the bean class of an EJB named Foo?
A: FooBean.
