answer 21)
2) the add method returns false if you attempt to add an element with a duplicate value
i find it a surprise that you do not get an exception.
answer 22)
1) the program exits via a call to exit(0);
2) the priority of another thread is increased
3) a call to the stop method of the thread class
note that this question asks what can cause a thread to stop executing, not what will cause a thread to stop executing. java threads are somewhat platform dependent and you should be carefull when making assumptions about thread priorities. on some platforms you may find that a thread with higher priorities gets to "hog" the processor. you can read up on this in more detail at
answer 23)
4) the class can only access final variables
answer 24)
1) to call from the currently running thread to allow another thread of the same or higher priority to run
option 3 looks plausible but there is no guarantee that the thread that grabs the cpu time will be of a higher priority. it will depend on the threading algorithm of the java virtual machine and the underlying operating system
answer 25)
4) compilation and running with output 0 to 9
answer 26)
1) none of these options
because of the lack of a break statement after the break 10; statement the actual output will be
"ten" followed by "twenty"
answer 27)
4) system.gc();
answer 28)
1) compilation succeeds and at run time an output of 0 and false
the default value for a boolean declared at class level is false, and integer is 0;
answer 29)
1) compile time error
you will get an error saying something like "cant make a static reference to a non static variable". note that the main method is static. even if main was not static the array argv is local to the main method and would thus not be visible within amethod.
answer 30)
3) output of "not equal"
despite the actual character strings matching, using the == operator will simply compare memory location. because the one string was created with the new operator it will be in a different location in memory to the other string.
上一页 [1] [2] [3] [4] [5] [6] 下一页
责任编辑:小草