在Applet画面的左上角至右下角画一条直线,则//draw处应如何选择?import java.awt.*;import java.applet.*;public class myApplet extends Applet {public void paint(Graphics g) {//draw}}
A. g.drawLine(0,0,getHeight(),getWidth());
B. g.drawLine(0,getWidth(),0,getHeight());
C. g.drawLine(0,getWidth(),getHeight(),0);
D. g.drawLine(getWidth(),getHeight(),0,0);
在同一目录编译和运行以下两文件结果如何?
//文件 P1.java
package MyPackage;
class P1{
void afancymethod(){
System.out.println("What a fancy method");
}
}
//文件 P2.java
public class P2 extends P1{
public static void main(String argv[]){
P2 p2 = new P2();
p2.afancymethod();
}
}
A. 两个均通过编译,P2运行时输出 What a fancy method
B. 没一个通过编译
C. 两个均通过编译,但P2运行时出错
D. P1 通过编译,但P2出现编译错误
下列程序运行的结果为:public class test {public static void main(String args[]) {int i;float f = 2.3f;double d = 2.7;i = ((int)Math.ceil(f)) * ((int)Math.round(d));System.out.println(i);}}
A. 4
B. 5
C. 6
D. 6.1
E. 9