Rob Camick wrote:
AWT which two specific areas of the screen have changed and need to be redrawn,
It does NOT redraw two specific areas of the screen.
It only redraws one larger area of the screen.
If you have the original square at (0, 0) and click at (100, 100), then it will redraw an Rectangle on (0, 0, 120, 120). So redraws a large rectangle, not the specific areas.
So if the areas are close to one another only a small area is painted. If the areas are far apart then a large area is repainted.
the two calls to repaint() that occur within moveSquare() tell AWT which two specific areas of the screen have changed and need to be redrawn
Rob Camick wrote:
tell AWT which two specific areas of the screen have changed and need to be redrawn, ie the area where the square was and the area where the square is.
No that is not accurate.
It does not track the specific areas that need to be withdrawn.
It tracks the smallest rectangular area that contains the two areas to be drawn and then repaints that area in one paint request.
Reread my answer and look at the calculation for this area to be redrawn.
Kaplan Self test practice explain it as...
Explanation:
A default constructor can be overloaded in a subclass. If no constructor is defined for a
class, then the compiler will automatically provide the default constructor. Because a
subclass can define its own constructors without affecting the superclass, a constructor with
parameters can be defined that invokes the superclass constructor, implicitly or explicitly.
[...]
The constructor must not use a different name. In the same class, an overloaded constructor
uses the same name. Because subclasses differ in name from their superclass, an
overloaded constructor will have a different name.
Christian Pflugradt wrote: As far as casting is concerned the compiler will detect an attempt to cast to a completely unrelated object (like casting a Date to a String) but it won't detect incorrect downcasts.
I don't know the exact specifications, so if someone could point us to official documentation regarding which casting errors the compiler can detect I'd be grateful.
Fred Kleinschmidt wrote:The 'this' keyword should never be used this way when initializing instance variables. [...]
The problem is that the instance is not fully complete before the constructor finishes, so this.xxx() may try to reference things that are not yet initialized.
Instance initializers are permitted to refer to the current object via the keyword this (§15.8.3), to use the keyword super (§15.11.2, §15.12), and to use any type variables in scope.
Use of instance variables whose declarations appear textually after the use is sometimes restricted, even though these instance variables are in scope.