JAVA认证格林模拟试题三(下)
来源:优易学  2011-11-28 15:22:42   【优易学:中国教育考试门户网】   资料下载   IT书店
question 31)

which of the following statements are true?

1) the default layout manager for an applet is flowlayout
2) the default layout manager for a frame is flowlayout
3) a layout manager must be assigned to an applet before the setsize method is called
4) the flowlayout manager attempts to honor the preferred size of any components


question 32)

which of the following statements are true about a variable created with the static modifier?

1) once assigned the value of a static variable may not be altered
2) a static variable created in a method will keep the same value between calls
3) only one instance of a static variable will exist for any amount of class instances
4) the static modifier can only be applied to a primitive value


question 33)

which of the following statements are true?

1) java uses a system called utf for i/o to support international character sets
2) the randomaccessfile is the most suitable class for supporting international character sets
3) an instance of fileinputstream may not be chained to an instance of fileoutputstream
4) file i/o activities requires use of exception handling


question 34)

what will happen when you attempt to compile and run the following code?

  import java.io.*;
class exbase{
    abstract public void martley(){       
    }
}
public class myex extends exbase{
    public static void main(string argv[]){
        datainputstream fi = new datainputstream(system.in);
        try{
     fi.readchar();
        }catch(ioexception e){
     system.exit(0);
        }
        finally {system.out.println("doing finally");}
    }
}    

1) compile time error
2) it will run, wait for a key press and then exit
3) it will run, wait for a keypress, print "doing finally" then exit
4) at run and immediately exit

question 35)

what will happen when you attempt to compile and run the following code

public class borley extends thread{
    public static void main(string argv[]){
        borley b = new borley();
        b.start();
    }
    public void run(){      
        system.out.println("running");
    }
}

1) compilation and run but no output
2) compilation and run with the output "running"
3) compile time error with complaint of no thread target
4) compile time error with complaint of no access to thread package


question 36)

assuming any exception handling has been set up, which of the following will create an instance of the randomaccessfile class

1) randomaccessfile raf=new randomaccessfile("myfile.txt","rw");
2) randomaccessfile raf=new randomaccessfile( new datainputstream());
3) randomaccessfile raf=new randomaccessfile("myfile.txt");
4) randomaccessfile raf=new randomaccessfile( new file("myfile.txt"));


question 37)

given the following class definition

public class upton{
public static void main(string argv[]){     
        }
        public void amethod(int i){}
        //here
}

which of the following would be legal to place after the comment //here ?
1) public int amethod(int z){}
2) public int amethod(int i,int j){return 99;}
3) protected void amethod(long l){ }
4) private void anothermethod(){}

question 38)

which of the following statements are true?

1) code must be written if the programmer wants a frame to close on selecting the system close menu
2) the default layout for a frame is the borderlayout manager
3) the layout manager for a frame cannot be changed once it has been assigned
4) the gridbaglayout manager makes extensive use of the the gridbagconstraints class.


question 39)

given the following class definition

public class droitwich{
        class one{
                private class two{
                        public void main(){
                        system.out.println("two");
                        }
                }
        }
}

which of the following statements are true


1) the code will not compile because the classes are nested to more than one level
2) the code will not compile because class two is marked as private
3) the code will compile and output the string two at runtime
4) the code will compile without error


question 40)

given the following code

class base{
static int oak=99;
}
public class doverdale extends base{
public static void main(string argv[]){
        doverdale d = new doverdale();
        d.amethod();
        }
        public void amethod(){
        //here
        }       
}

which of the following if placed after the comment //here, will compile and modify the value of the variable oak?

1) super.oak=1;
2) oak=33;
3) base.oak=22;
4) oak=50.1;

[1] [2] [3] 下一页

责任编辑:小草

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