A、ArrayIndexOutOfBoundException
B、ClassCastException
C、ArithmeticException
D、No exception
A、ArrayIndexOutOfBoundException
B、ClassCastException
C、ArithmeticException
D、No exception
1)public class Test {
2)int m, n;
3)public Test() ()
4)public Test(int a) {m=a; }
5)public static void main(string arg[]) {
6)Test t1,t2;
7)int j,k;
8)j=O; k=0;
9)t1=rlew Test();
10)t2=new Test(j,k);
11)}
12)}
在编译时行将导致一个错误。
A.3 B.5 C.6 D.10
A、O(n)
B、O(n^2)
C、O(log n)
D、O(n^3)
A、public Test(int a) { m=a; }
B、j=3;k=5;
C、t1=new Test23();
D、t2=new Test23(k);
A、第1 行声明的param 参数未在方法内使用。删除该参数;
B、第3 行修改为:using( Resource r1 = new Resource(100);) {
C、删除第5 行
D、第5 行修改为:r1=r0;
【说明】
以下程序实现数据的排序,将n个整数分别按照升序和降序进行排序,类SortInt_1实现升序排序,类SortInt_2实现降序排序。
【Java代码】
class SortInt_1{
int i,i,k,temp;
void SortInt(int a1,int a2[]){//升序排序
for(i=0;i<a1-1;i++){
k=i;
for(j=i+1;j<a1;j++){
if((1)) k=j;
if(k !=i){
temp=a2[i];a2[i]=a2[k];a2[k]=temp;
}
}
}
}
}
class SortInt_2 (2) {
int i,j,k,temp;
void SortInt(int a1, int a2[]){//降序排序
for(i=0; i<a1-1;i++){
k=i;
for(j=i+1;j<a1;j++){
if((3))k=j;
}
if(k !=i){
temp=a2[i];a2[i]=a2[k];a2[k]=temp;
}
}
}
}
public class test{
public static void main(String args[]){
int a[]={10,55,100,35,87,90,100,16};
SortInt_1 NewInt=(4);
NewInt.SortInt(a.lenvh,a);//调用SortInt_1类的方法
System.out.println("升序排列的数据: ");
for(int i=0;i<a.length;i++){
System.out.print(a[i]+" ");
}
System.out.println();
NewInt=new SortInt_2();//创建类SortInt_2的对象
(5);//调用相应方法进行降序排序
System.out.println("降序排列的数据: ");
for(int i=0;i<a.length;i++){
System.out.print(a[i]+" ");
}
}
}
A、Cell. drop()是调用drop方法的正确方式
B、Cell.move()是调用move方法的正确方式
C、drop方法可以直接调用move方法
D、move方法可以盲接调用drop方法
[说明]
以下程序为类类型的变量应用实例,通过异常处理检验了类CCircle的变量的合法性,即参数半径应为非负值。仔细阅读代码和相关注释,将程序补充完整。
[JAVA代码]
//定义自己的异常类
class CCircleException extends Exception
{
}
// 定义类 CCircle
class CCircle
{
private double radius;
public void setRadius (double r ) (1)
{
if (r<0 ) {
(2)
}
else
(3)
}
Public void show () {
System. out. println ("area="+3.14*radius*radius );
}
}
public class ciusample
{
public static void main (String args[] )
{
CCircle cir=new CCircle();
(4) {
cir. setRadius (-2.0 )
}
(5)
{
System. out. println (e+" throwed" ) ;
}
cir. show() ;
}
}
为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!