JAVA题库:格林模拟试题二(上)5
来源:优易学  2010-1-15 11:37:23   【优易学:中国教育考试门户网】   资料下载   IT书店
Question 27)
Which of the following is the correct syntax for suggesting that the JVM performs garbage collection
1) System.free();
2) System.setGarbageCollection();
3) System.out.gc();
4) System.gc();

Question 28)

What will happen when you attempt to compile and run the following code
public class As{    int i = 10;    int j;    char z= 1;    boolean b;    public static void main(String argv[]){ As a = new As(); a.amethod();    }    public void amethod(){        System.out.println(j);        System.out.println(b);                    }}
1) Compilation succeeds and at run time an output of 0 and false
2) Compilation succeeds and at run time an output of 0 and true
3) Compile time error b is not initialised
4) Compile time error z must be assigned a char value

Question 29)

What will happen when you attempt to compile and run the following code with the command line "hello there"
public class Arg{String[] MyArg;        public static void main(String argv[]){        MyArg=argv;        }        public void amethod(){                System.out.println(argv[1]);        }}
1) Compile time error
2) Compilation and output of "hello"
3) Compilation and output of "there"
4) None of the above

Question 30)
What will happen when you attempt to compile and run the following code
public class StrEq{public static void main(String argv[]){        StrEq s = new StrEq();        }        private StrEq(){                String s = "Marcus";                String s2 = new String("Marcus");                if(s == s2){                        System.out.println("we have a match");                        }else{                        System.out.println("Not equal");                }       }}
1) Compile time error caused by private constructor
2) Output of "we have a match"
3) Output of "Not equal"
4) Compile time error by attempting to compare strings using

责任编辑:cyth

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