1,2
value for i=1 value for j=1
value for i=2 value for j=1
the statement continue outer causes the code to jump to the label outer and the for loop increments to the next number.
answer 22)
4) runtime error, an exception will be thrown
a call to wait/notify must be within synchronized code. with jdk1.2 this code throws the error message
java.lang.illegalmonitorstateexception: current thread not owner
at java.lang.object.wait(native method)
at java.lang.object.wait(object.java:424)
at dsross.notwait(compiled code)
at dsross.run(agg.java:21)
2,3
options 1, & 4 will not compile as they attempt to throw exceptions not declared in the base class. because options 2 and 3 take a parameter of type long they represent overloading not overriding and there is no such limitations on overloaded methods.
3) system.out.println(math.ceil(-4.7));
options 1 and 2 will produce -5 and option 4 will not compile because the min method requires 2 parameters.
3) compile time error
the wrapper classes cannot be used like primitives.
depending on your compiler you will get an error that says someting like "error: can't convert java lang integer". wrapper classes have similar names to primitives but all start with upper case letters.
thus in this case we have int as a primitive and integer as a wrapper. the objectives do not specifically mention the wrapper classes but don't be surprised if they come up.
2) ic
this is a bit of a catch question. anyone with a c/c++ background would figure out that addressing in strings starts with 0 so that 1 corresponds to i in the string bicycle. the catch is that the second parameter returns the endcharacter minus 1. in this case it means instead of the "icy" being returned as intuition would expect it is only "ic".
3) s.indexof('v');
charat returns the letter at the position rather than searching for a letter and returning the position, mid is just to confuse the basic programmers, indexof(s,'v'); is how some future vb/j++ nightmare hybrid, might perform such a calculation.
1) s3=s1 + s2;
java does not allow operator overloading as in c++, but for the sake of convenience the + operator is overridden for strings.
4) 7
the | is known as the or operator, you could think of it as the either/or operator. turning the numbers into binary gives
4=100
3=011
for each position, if either number contains a 1 the result will contain a result in that position. as every position contains a 1 the result will be
111
which is decimal 7.
1,2,3
public, private, static are all legal access modifiers for this inner class.
责任编辑:小草