JAVA认证格林模拟试题一(下)
来源:优易学  2009-11-28 14:55:06   【优易学:中国教育考试门户网】   资料下载   IT书店
文章页内部300*250广告位
 
question 51)

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

public class scope{
private int i;
public static void main(string argv[]){
scope s = new scope();
s.amethod();
}//end of main
public static void amethod(){
system.out.println(i);
}//end of amethod
}//end of class


1) a value of 0 will be printed out
2) nothing will be printed out
3) a compile time error
4) a compile time error complaining of the scope of the variable i

question 52)
you want to lay out a set of buttons horizontally but with more space between the first button and the rest. you are going to use the gridbaglayout manager to control the way the buttons are set out. how will you modify the way the gridbaglayout acts in order to change the spacing around the first button?
 

1) create an instance of the gridbagconstraints class, call the weightx() method and then pass the gridbagconstraints instance with the component to the setconstraints method of the gridbaglayout class.
2) create an instance of the gridbagconstraints class, set the weightx field and then pass the gridbagconstraints instance with the component to the setconstraints method of the gridbaglayout class.
3) create an instance of the gridbaglayout class, set the weightx field and then call the setconstraints method of the gridbaglayoutclass with the component as a parameter.
4) create an instance of the gridbaglayout class, call the setweightx() method and then pass the gridbagconstraints instance with the component to the setconstraints method of the gridbaglayout class.

question 53)
which of the following can you perform using the file class?

1) change the current directory
2) return the name of the parent directory
3) delete a file
4) find if a file contains text or binary information

question 54)

which statement is true of the following code?

public class rpcraven{
public static void main(string argv[]){
pmcraven pm1 = new pmcraven("one");
pm1.run();
pmcraven pm2 = new pmcraven("two");
pm2.run();

}
}

class pmcraven extends thread{
private string stname="";
pmcraven(string s){
stname = s;

}
public void run(){
for(int i =0; i < 2 ; i++){
try{
sleep(1000);
}catch(interruptedexception e){}

yield();
system.out.println(stname);
}

}
}

1) compile time error, class rpcraven does not import java.lang.thread
2) output of one one two two
3) output of one two one two
4) compilation but no output at runtime

question 55)

you are concerned that your program may attempt to use more memory than is available. to avoid this situation you want to ensure that the java virtual machine will run its garbage collection just before you start a complex routine. what can you do to be certain that garbage collection will run when you want .

1) you cannot be certain when garbage collection will run
2) use the runtime.gc() method to force garbage collection
3) ensure that all the variables you require to be garbage collected are set to null
4) use the system.gc() method to force garbage collectionx2s

question 56)

you are using the gridbaglayout manager to place a series of buttons on a frame. you want to make the size of one of the buttons bigger than the text it contains. which of the following will allow you to do that?

1) the gridbaglayout manager does not allow you to do this
2) the setfill method of the gridbaglayout class
3) the setfill method of the gridbagconstraints class
4) the fill field of the gridbagconstraints class 

question 57)

which of the following most closely describes a bitset collection?

1) a class that contains groups of unique sequences of bits
2) a method for flipping individual bits in instance of a primitive type
3) an array of boolean primitives that indicate zeros or ones
4) a collection for storing bits as on-off information, like a vector of bits

question 58)
you have these files in the same directory. what will happen when you attempt to compile and run class1.java if you have not already compiled base.java

//base.java
package base;
class base{
protected void amethod(){
system.out.println("amethod");
}//end of amethod
}//end of class base
package class1;
//class1.java
public class class1 extends base{
public static void main(string argv[]){
base b = new base();
b.amethod();
}//end of main

}//end of class1




1) compile error: methods in base not found
2) compile error: unable to access protected method in base class
3) compilation followed by the output "amethod"
4)compile error: superclass class1.base of class class1.class1 not found

question 59)

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

class base{
private void amethod(int ibase){
system.out.println("base.amethod");
}
}



class over extends base{
public static void main(string argv[]){
over o = new over();
int ibase=0;
o.amethod(ibase);
}

public void amethod(int iover){
system.out.println("over.amethod");
}
}

1) compile time error complaining that base.amethod is private
2) runtime error complaining that base.amethod is private
3) output of "base.amethod"
4) output of "over.amethod" 

question 60)

you are creating an applet with a frame that contains buttons. you are using the gridbaglayout manager and you have added four buttons. at the moment the buttons appear in the centre of the frame from left to right. you want them to appear one on top of the other going down the screen. what is the most appropriate way to do this.
 

1) set the gridy value of the gridbagconstraints class to a value increasing from 1 to 4
2) set the fill value of the gridbagconstraints class to vertical
3) set the ipady value of the gridbagconstraints class to a value increasing from 0 to 4
4) set the fill value of the gridbaglayouts class to gridbag.vertical

上一页  [1] [2] [3] 

责任编辑:小草

收藏此页】【 】【打印】【回到顶部
计算机文章页底部500*200广告
文章搜索:
 相关文章
计算机底部580*90广告
文章页右侧第一330*280广告
计算机文章页资讯推荐
热点资讯
文章页330尺寸谷歌广告位
热门课程培训