题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-02-23 06:15:55

[单选题]下列程序的输出结果是: public class Test{   public static void main(String[] args){     int [] array={2,4,6,8,10};     int size=6;     int result=-1;     try{       for(int i=0;i<size && result==-1;i++)         if(array[i]==20) result=i;     }catch(ArithmeticException e){       System.out.println("Catch---1");     }catch(ArrayIndexOutOfBoundsException e){       System.out.println("Catch---2");     }catch(Exception e){       System.out.println("Catch---3");     }   } }
A.Catch---1
B.Catch---2
C.Catch---3
D.以上都不对

更多"[单选题]下列程序的输出结果是: public class Test{"的相关试题:

[单选题]下列程序的运行结果是: public class test{   private String[] data={"10","10.5"};   public void fun(){     double s=0;     for(int i=0;i<3;i++){       try{         s=s+Integer .parseInt(data[i]);       }catch(Exception e{         System.out.print("errorl:"+data[i]);       }     }   }   public static void main(String[]args){     try{       test d=new test();       d .fun();     }catch(Exception e){       System.out.println("error2");     }   } }
A.errorl:10.5
B.error2
C.errorl:10.5 error2
D.以上都不对
[单选题]下列代码的执行结果是 public class Test { public int aMethod() { static int i=0; i++; System.out.println(i); } public static void main(String args[]) { Test test = new Test(); test.aMethod(); } }
A.编译错误
B.0
C.1
D.运行成功,但不输出
[单选题]下列代码的执行结果是: public class Test { public static void main(String[] args) { int[] x={0,1,2,3}; for(int i=0;i<3;i+=2){ try{ System.out.println(x[i+2]/x[i]+x[i+1]); }catch(ArithmeticException e){ System.out.println("error1"); }catch(Exception e){ System.out.println("error2"); } } } }
A.error1
B.error2
C.error1 error2
D.2 error2
[单选题]阅读下列程序 public class Test implements Runnable{   private int x=0;   private int y=o;   boolean flag=true;   public static void main(string[ ] args) {     Test r =new Test( );     Thead t1=new Thead(r);     Thead t2=new Thead(r);     t1.start( );     t2.start( );   }   public void run(){     while(flag) {       x++;       y++;       System.out.println("(" +x_ ","+y+")");       if (x>=10)         flag=false;     }   } } 下列对程序运行结果描述的选项中,正确的是:
A.每行的(x,y)中,可能有;每一对(x,y)值都出现两次。
B.每行的(x,y)中,可能有;每一对(x,y)值仅出现一次。
C.每行的(x,y)中,可能有x=y;每一对(x,y)值都出现两次。
D.每行的(x,y)中,可能有x=y;每一对(x,y)值都出现一次。
[单选题]在程序的下划线处应填入的选项是: public class Test_____{   public static void main(String args[]){     Test t = new Test();     Thread tt = new Thread(t);     tt.start();   }   public void run(){     for(int i=0;i<5;i++){       System.out.println("i="+i);     }   } }
A.implements Runnable
B.extends Thread
C.implements Thread
D.extends Runnable
[单选题]已知有下列类的说明,则下列哪个语句是正确的? public class Test { private float f = 1.0f; int m = 12; static int n=1; public static void main(String arg[]) { Test t = new Test(); } }
A.t.f;
B.this.n;
C.Test.m;
D.Test.f;
[单选题]阅读下列程序 public class VariableUse{ public static void main (String[] args) { int a; if (a==8) { int b=9; System.out.println("a = "+a); System.out.println("b = "+b); } System.out.println("a = "+a); System.out.println("b = "+b); } } 该程序在编译时的结果是:
A.变量a未赋值
B.第二个System.out.println(“b = ”+b)语句中,变量b作用域有错
C.第二个System.out.println(“a = ”+a)语句中,变量a作用域有错
D.第一个System.out.println(“b = ”+b)语句中,变量b作用域有错
[单选题]下列代码的编译或执行结果是: public class MyVal { public static void main(String[] args) { MyVal m = new MyVal(); m.aMethod(); } public void aMethod(){ boolean [] b = new Boolean [5]; System.out.println(b[0]); } }
A.1
B.null
C.0
D.编译错误
[单选题]下面的程序创建了一个文件输出流对象,用来向文件test.txt中输出数据,假设程序当前目录下不存在文件test.txt,编译下面的程序Test.java后,将该程序运行3次,则文件test.txt 的内容是( )。 import java.io.*; public class Test { public static void main(String args[]) { try { String s="ABCDE"; byte b[]=s.getBytes(); FileOutputStream file=new FileOutputStream("test.txt",true); file.write(b); file.close(); }catch(IOException e) { System.out.println(e.toString()); } } }
A.ABCABC
B.ABCDE
C. Test
D.ABCDE ABCDE ABCDE
[单选题]对下列程序的叙述中,正确的是:   1:public class X extends Thread implements Runnable{   2:  public void run(){   3:    System.out.println("this is run()");   4:  }   5:  public static void main(String args[]){   6:    Thread t=new Thread(new X());   7:    t.start();   8:  }   9:}
A.第1行会产生编译错误
B.第6行会产生编译错误
C.第6行会产生运行错误
D.程序正常运行
[单选题]以下程序输出结果是 。 #include "stdio.h" void f (); main() {int a; for(a=1;a<=3;a++) fun(); } void fun() {static int i=1; i+=3; printf("%2d",i); }
A.4 7 10
B.4 4 4
C.4 5 6
D.4 6 8
[单选题]下列代码编译或执行结果的描述中,正确的是: class Test{ public static void main(String args[]){ TestThread pm1 = new TestThread("One"); pm1.start(); TestThread pm2 = new TestThread("Two"); pm2.start(); } } class TestThread extends Thread{ private String sTname=""; TestThread(String s){ sTname = s; } public void run(){ for(int i=0;i<2;i++){ try { sleep(1000); } catch (InterruptedException e) {} System.out.println(sTname+" "); } } }
A.不能通过编译,TestThread 类中不能定义变量和构造方法
B.输出One One Two Two
C.输出Two One One Two
D.选项B 或C 都有可能出现
[单选题]以下程序的输出结果是( ) #define M(x,y,z) x*y+z void main() { int a=1,b=2, c=3; cout<A.19
B.17
C.15
D.12

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码