3) output of first0, first1, second0, second1
note that this code overrides and calls the start method. if you wished to get the output mixed you would need to override the run method but call the start method.
2) setlayout(new gridlayout(2,2));
changing the layout manager is the same for an applet or an application. answer 1 is wrong though it might have been a reasonable name for the designers to choose. answers 3 and 4 are incorrect because changing the layout manager always requires an instance of one of the layout managers and these are bogus methods.
instead of creating the anonymous instance of the layout manager as in option 2 you can also create a named instance and pass that as a parameter. this is often what automatic code generators such as borland/inprise jbuilder do.
3) the code will cause an error at compile time
the error is caused because run should have a void not an int return type.
any class that is implements an interface must create a method to match all of the methods in the interface. the runnable interface has one method called run that has a void return type.the sun compiler gives the error
method redefined with different return type: int run() was defined as void run();
3) compilation and output of 0 followed by 1
the creation of an anonymous class as a parameter to go is fairly strange as you would expect it to override a method in its parent class (turing). you don't have to though. the fact that class turing extends thread means the anonymous instance that is passed to go has a start method which then calls the run method.
4) compile time error
the only operator overloading offered by java is the + sign for the string class. a char is a 16 bit integer and cannot be concatenated to a string with the + operator.
3) if(s.equalsignorecase(s2))
string comparison is case sensitive so using the equals string method will not return a match. using the==operator just compares where memory address of the references and nocasematch was just something i made up to give me a fourth slightly plausible option.
1) s.setbackground(color.pink);
for speakers of the more british spelt english note that there is no letter u in color. also the constants for colors are in lower case.
4) the file class does not support directly changing the current directory.
this seems rather surprising to me, as changing the current directory is a very common requirement. you may be able to get around this limitation by creating a new instance of the file class passing the new directory to the constructor as the path name.
1)with a fixed font you will see 5 characters, with a proportional it will depend on the width of the characters
with a proportional font the letter w will occupy more space than the letter i. so if you have all wide characters you may have to scroll to the right to see the entire text of a textfield.
3) on the line after //two put super(10);
constructors can only be invoked from within constructors.
责任编辑:小草