posted 24 years ago
An anonymous inner class either implements an interface OR extends an object. You lost me on the non-static class part. An anonymous class is either static or non-static based on the CONTEXT of the declaration (if in a static method it is a static inner class). The access rules for member and local variables are governed like any other inner class.
To construct an extended object
new TheObject([any existing constructor args]) {};
You can't specify your own constructor, so if you need to set additional member variables you can specify an instance initializer, but not your own constructor.
To construct an interface
new InterfaceName ([no arguments allowed!]) {};
The object extends Object.
Question 2....
An implicit cast is done for you if and only if the right side is a type of INT and it's value is known at compile time (i.e., final) and the value is in range of the left type.
So you have a final int=2 being assigned to a byte. Remove the final and error, change to short and error, change to 128 and error.