JAVA題庫:格林模擬試題二(下)(2)

question 33)what will happen when you attempt to compile and run this code

//demonstration of event handling
import java.awt.*;
import java.awt.event.*;
public class mywc extends frame implements windowlistener{
public static void main(string argv[]){
mywc mwc = new mywc();
}
public void windowclosing(windowevent we){
system.exit(0);
}//end of windowclosing
public void mywc(){
setsize(300,300);
setvisible(true);
}
}//end of class
1) error at compile time
2) visible frame created that that can be closed
3) compilation but no output at run time
4) error at compile time because of comment before import statements

question 34)which option most fully describes will happen when you attempt to compile and run the following code

public class myar{
public static void main(string argv[]) {
myar m = new myar();
m.amethod();
}
public void amethod(){
static int i;
system.out.println(i);
}
}

1) compilation and output of the value 0
2) compile time error because i has not been initialized
3) compilation and output of null
4) compile time error

question 35)which of the following will compile correctly

1) short myshort = 99s;
2) string name = 'excellent tutorial mr green';
3) char c = 17c;
4)int z = 015;