| Terms |
Definitions |
|
public class SunRoof{}public class SexAppeal{}public class ManualTransmission{}public class Vehicle{}public class Car extends Vehicle{ private SunRoof sr;}public class Mustang extends Car{ private SexAppeal sa; private ManualTransmission mt;}True or False
|
False
|
|
is an enum an int
|
no
|
|
Interfaces methods can be static. (T/F)
|
False
|
|
can static methods access non-static members?
|
no
|
|
does wait give up the lock?
|
yes
|
|
T/F: Java identifiers are case sensitive.
|
T(p. 5)
|
|
can a subclass inherit a public superclass member
|
yes
|
|
can a class be abstract and final?
|
no
|
|
Which figure is important?
|
9-3 on page 727
|
|
For an example of synchronized code blocks where do i look?
|
ThreadsExample3.java
|
|
Which of the following are NON-valid characters for the characters following the first character of a legal Java identifier?a. numberb. letterc. underscored. percent character (%)e. currency character ($)
|
d(p. 5)
|
|
what is MyEnum.values()
|
returns an array of MyEnum's values
|
|
Look at the three points on page ...
|
668
|
|
When you call start() on a thread object, the thread moves from the new state to the _________ state.
|
runnable
|
|
True / FalseStatic variables cannot be serialized.
|
True. (pg472)
|
|
What is the result?public class Test { public static void main (String args[]){ int[] x = new int[5]; System.out.println(x[1]); Test [] test = new Test[5]; System.out.println(test[1]); }}
|
0null(pg. 58)
|
|
what comes first package or import statement?
|
package then import
|
|
How do you instantiate an inner class from within the outer class?
|
page 666
|
|
Which exam watch is important?
|
The one on page 723
|
|
What is the syntax for the printf statement and its format string?
|
printf statement:printf("format string", argument(s));format string:%[arg_index$][flags][width][.precision]conversion_char(p. 506/507)
|
|
can a class implement multiple interfaces?
|
yes but only one class.
|
|
who can access private members?
|
only code in the same class
|
|
Which important points should be looked at?
|
at the bottom of 727
|
|
How is a pattern and matcher created?
|
Pattern p = Pattern.compile("pattern expression");Matcher m = p.matcher("source");
|
|
interface AInterface { void doAThings();}public abstract class A implements AInterface { public abstract void doMoreThings(); public String doSomething() { }}public abstract class B extends A { public void doAThings() { }}
What extra methods
|
class B is required to implement doMoreThings().
|
|
what access level can members have?
|
all four: public, protected, efault, private
|
|
What is important to know about the output of the code on page 713
|
That it's not guaranteed
|
|
T/F: The following identifier is legal:int e#;
|
False - Identifier contains an illegal character (#).(Ref: p. 5)
|
|
T/F - Contructors can be overloaded and overridden but are never inherited.
|
False - Constructors are not methods. They cannot be overridden.
|
|
True or False: method-local inner classes can be marked public, abstract, static, final
|
false (they are treated as local variables of the method), true, false, true
|
|
So how do you replace a synchronized static method with a synchronized block code in a static method?
|
synchronized(MyClass.class){ ... } // look at the top of 738
|
|
Define how each of the following patterns work, and what would m.start() return after m.find()[abc][a-f][a-fA-F].*[abc]
|
character 'a' or 'b' or 'c'character 'a' or 'b' or 'c' or 'd' or 'f'character 'a' or 'b' or 'c' or 'd' or 'f' or 'A' or 'B' or 'C' or 'D' or 'F'any number of characters followed by an 'a', or 'b' or 'c'pg391-396
|
|
what is an inteface?
|
a contract for what a class can do. no implementation
|
|
So the scheduler chooses a Thread in the Runnable state. The thread to choose is not guaranteed. How can we influence the scheduler?
|
sleep, yield, join, setPriority. Look at the bottom of page 717
|
|
Define the meaning of the following flags used in a format string:a) "-"b) "+"c) "0"d) ","e) "("
|
a) "-" Left justify the argumentb) "+" Include a sign (+ or -) with the argumentc) "0" Pad the argument with zerosd) "," Use locale-specific grouping separators (e.g. the comma in 123,456)e) "(" Enclose negative numbers in parentheses(p. 507)
|
|
If a source code file contains import statements, where must they appear?
|
Import statements must go between the package statement (if there is one) and the class declaration.(p. 11)
|
|
class Frog { Frog(String name) { }}T/F - The compiler will put in a default constructor for class Frog.
|
False - Default constructor will be created only if you don't write any constructors in your class. (pg 135)
|
|
Regular inner classes are treated as members of the outer classes, just as methods and instance variables to outer classes are. So what does that tell you about the access modifiers for the inner classes?
|
that you can apply the following to the inner classes: public private, protected, strictfp, final, abstract, and static (that doesn't make it an inner class, but a static nested class)
|
|
What is the only guarantee with threads?
|
That each thread will start, and each thread will run to completion
|
|
class ArrayExample { public static void main(String[] args) { int x = 0; int[] tempArray; tempArray = new int[3] {4,x,2}; System.out.println(tempArray[2]);}}T/F - The following code will compile correctly and output 0.
|
False - You cannot specify a size for an anonymous array creation syntax. (pg 230)
|
|
T/F: The following is a legal class declaration:public abstract final Ferrari { }
|
F - cannot use abstract and final together(p. 15)
|
|
So method-local inner classes can only be used from within the method itself. and it can be instantiated after the inner class definition inside the method
|
For an example look at the code on page 671
|
|
What are the three ways one can remove a reference to an object, thereby making it eligible for garbage collection?
|
1. Set the reference to null.2. Set the reference variable to refer to another object3. Isolate a reference (make them an island, so that even if two objects reference one another, those objects themselves cannot be reached by any thread).(p. 257-259)
|
|
When can a class access a protected variable?
|
a) When it is defined in the same classb) When it is defined in a super-classc) When it is in the same package
|
|
Can you create multiple Threads with one Runnable target?
|
Yes. Look at the code at the bottom of 707. The same job will be executed multiple times
|