JAVA题库:格林模拟试题二(上)4
来源:优易学  2010-1-15 11:36:44   【优易学:中国教育考试门户网】   资料下载   IT书店

Question 22)
What can cause a thread to stop executing?
1) The program exits via a call to System.exit(0);
2) Another thread is given a higher priority
3) A call to the thread’s stop method.
4) A call to the halt method of the Thread class 
 
Question 23)
For a class defined inside a method, what rule governs access to the variables of the enclosing method?
1) The class can access any variable
2) The class can only access static variables
3) The class can only access transient variables
4) The class can only access final variables

Question 24)

Under what circumstances might you use the yield method of the Thread class
1) To call from the currently running thread to allow another thread of the same or higher priority to run
2) To call on a waiting thread to allow it to run
3) To allow a thread of higher priority to run
4) To call from the currently running thread with a parameter designating which thread should be allowed to run

Question 25)
What will happen when you attempt to compile and run the following code
public class Hope{    public static void main(String argv[]){ Hope h = new Hope();    }    protected Hope(){ for(int i =0; i <10; i ++){     System.out.println(i); }    }}
1) Compilation error: Constructors cannot be declared protected
2) Run time error: Constructors cannot be declared protected
3) Compilation and running with output 0 to 10
4) Compilation and running with output 0 to 9

Question 26)
What will happen when you attempt to compile and run the following code
public class MySwitch{public static void main(String argv[]){    MySwitch ms= new MySwitch();    ms.amethod();    }public void amethod(){    int k=10;         switch(k){         default: //Put the default at the bottom, not here            System.out.println("This is the default output");             break;          case 10:             System.out.println("ten");         case 20:             System.out.println("twenty");         break;        }    }}
1) None of these options
2) Compile time error target of switch must be an integral type
3) Compile and run with output "This is the default output"
4) Compile and run with output of the single line "ten"

[1] [2] 下一页

责任编辑:cyth

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训