在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
如果以下条件成立,则用到java.lang.Math 类中哪个方法?method(-4.4 ) == -4;
A. round()
B. min()
C. trunc()
D. abs()
E. floor()
F. ceil()
设有如下程序
public class test {
public static void main(String args[]) {
Integer intObj=Integer.valueOf(args[args.length-1]);
int i = intObj.intValue();
if(args.length >1、
System.out.println(i);
if(args.length >0)
System.out.println(i -1、;
else
System.out.println(i - 2、;
}
}
运行程序,输入如下命令:
java test 2
则输出为:
A. test
B. test -1
C. 0
D. 1
E. 2