JAVA题库:格林模拟试题一(上)(6)
2012-12-26来源/作者:卫凯点击次数:370
question 20)
what will be displayed when you attempt to compile and run the following code
//code start
import java.awt.*;
public class butt extends frame{
public static void main(string argv[]){
butt mybut=new butt();
}
butt(){
button hellobut=new button("hello");
button byebut=new button("bye");
add(hellobut);
add(byebut);
setsize(300,300);
setvisible(true);
}
}
//code end
1) two buttons side by side occupying all of the frame, hello on the left and bye on the right
2) one button occupying the entire frame saying hello
3) one button occupying the entire frame saying bye
4) two buttons at the top of the frame one saying hello the other saying bye
question 21)
what will be output by the following code?
public class myfor{
public static void main(string argv[]){
int i;
int j;
outer:
for (i=1;i <3;i++)
inner:
for(j=1; j<3; j++) {
if (j==2)
continue outer;
system.out.println("value for i=" + i + " value for j=" +j);
}
}
}
1) value for i=1 value for j=1
2) value for i=2 value for j=1
3) value for i=2 value for j=2
4) value for i=3 value for j=1