要产生[20,999]之间的随机整数使用哪个表达式?
A.(int)(20+Math.random()*979)
B. 20+(int)(Math.random()*980)
C. (int)Math.random()*999
D. 20+(int)Math.random()*980
A.(int)(20+Math.random()*979)
B. 20+(int)(Math.random()*980)
C. (int)Math.random()*999
D. 20+(int)Math.random()*980
第1题
在同一目录编译和运行以下两文件结果如何?
//文件 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出现编译错误
第2题
A. 4
B. 5
C. 6
D. 6.1
E. 9
第3题
A. round()
B. min()
C. trunc()
D. abs()
E. floor()
F. ceil()
第4题
A.如果加入一个重复元素将抛出异常
B.如果加入一个重复元素add方法将返回false
C. 集合通过调用equals方法可以返回包含重复值的元素。
D. 重复值将导致编译出错。
第5题
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);
第7题
设有如下程序
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
第8题
A. 输出结果为 0
B. 运行出错
C. 输出结果为 null
D. 编译错误
第9题
A.getImage()方法无论图像是否存在,都立即返回
B.getImage()方法调用图像的时候,一直等图像加载完毕才返回
C.使用getImage()方法时,只有图像真正需要绘制时,数据才真正加载。
D.由于网络带宽的限制,图像的显示过程可能会很慢。
第10题
设有类定义如下:
class Base{
public Base(int i){}
}
public class MyOver extends Base{
public static void main(String arg[]){
MyOver m = new MyOver(10);
}
MyOver(int i){
super(i);
}
MyOver(String s, int i){
this(i);
//Here
}
}
以下哪条语句可以安排在//Here处 ?
A.MyOver m = new MyOver();
B.super();
C.this("Hello",10);
D.Base b = new Base(10);
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!