题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-02-12 00:26:36

[单选题]阅读下列代码段 class Test implements Runnable { public int run( ) { int i = 0; while (true) { i++; System.out.println ("i="+i); } } } 上述代码的编译结果是:
A.程序通过编译并且run ()方法可以正常输出递增的i值
B.程序通过编译,调用run ()方法将不显示任何输出
C.程序不能通过编译,因为while的循环控制条件不能为“true”
D.程序不能通过编译,因为run ()方法的返回值类型不是void

更多"[单选题]阅读下列代码段 class Test implements "的相关试题:

[单选题]阅读下列程序 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
[多选题] 类 Test1 定义如下:
1 . public class Test1{
2 . public float aMethod ( float a , float b ) { }
3 .
4 . }
将以下哪种方法插入行 3 是不合法的。( )
A. public float aMethod ( float a , float b , float c ) { }
B. public float aMethod ( float c , float d ) { }
C.public int aMethod ( int a , int b ) { }
D.private float aMethod ( int a , int b , int c ) { }
[单选题]考虑如下类:
1). class Test(int i) {
2). void test(int i) {
3). System.out.println("I am an int.");
4). }
5). void test(String s) {
6). System.out.println("I am a string.");
7). }
8).
9). public static void main(String args[]) {
10). Test t=new Test();
11). char ch="y";
12). t.test(ch);
13). }
14). }
以下哪条为真?
A.行 5 不能通过编译 , 方法不能被覆盖 .
B.行 12 不能通过编译 , 因为没有一个 test() 方法含字符参数 .
C.代码可以编译但在 12 行将出现异常 .
D.代码可以编译且产生如下输出 : I am an int.
E.代码可以编译且产生如下输出 : I am a String.
[单选题] 设有如下程序
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
[单选题]下列代码的执行结果是 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 [] array={2,4,6,8,10};     int size=6;     int result=-1;     try{       for(int i=0;iA.Catch---1
B.Catch---2
C.Catch---3
D.以上都不对
[单选题]下列程序的运行结果是: 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 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 {
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
[单选题] 下列代码的执行结果是: ( )
Public class Test1{
Public static void main(String args[]){
Float t=9.0f;
Int q=5;
System.out.println((t++)*(--q));
}
}
A. 40
B.40.0
C.36
D.36.0
[单选题] 以下程序调试结果为:
Public class Test {
Int m=5;
Public void some(int x) {
M=x;
}
Public static void main(String args []) {
New Demo().some(7);
}
}
Class Demo extends Test {
Int m=8;
Public void some(int x) {
Super.some(x);
System.out.println(m);
}
}
A.5
B. 8
C. 7
D.无任何输出
E.编译错误
[单选题]下列代码编译或执行结果的描述中,正确的是: 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 都有可能出现
[单选题]已知有下列类的说明,则下列哪个语句是正确的? 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;
[单选题] 在Java中,以下程序编译运行后的输出结果为( )。
Public class Test {
Int x, y;
Test(int x, int y) {
This.x = x;
This.y = y;
}
Public static void main(String[] args) {
Test pt1, pt2;
Pt1 = new Test(3, 3);
Pt2 = new Test(4, 4);
System.out.print(pt1.x + pt2.x);
}
}
A. 6
B. 3 4
C. 8
D. 7
[单选题]给出下列代码,如何使成员变量m 被方法fun()直接访问? class Test { private int m; public static void fun() { ... } }
A.将private int m 改为protected int m
B.将private int m 改为 public int m
C.将private int m 改为 static int m
D.将private int m 改为 int m
[单选题]以下程序的编译和运行结果为?
Abstract class Base{
Abstract public void myfunc();
Public void another(){
System.out.println("Another method");
}
}
public class Abs extends Base{
public static void main(String argv[]){
Abs a = new Abs();
a .amethod();
}
public void myfunc(){
System.out.println("My Func");
}
public void amethod(){
myfunc();
}
}
A.输出结果为 My Func
B.编译指示 Base 类中无抽象方法
C.编译通过,但运行时指示 Base 类中无抽象方法
D.编译指示 Base 类中的 myfunc 方法无方法体,没谁会喜欢该方法。
[判断题]( )在8088/8086系统中,程序代码被存放在代码段。
A.正确
B.错误
[单选题]分析下面的 JavaScript 代码段: function employee(name,code) { this.name="wangli"; this.code="A001"; } newemp=new employee("zhangming",'A002'); document.write("雇员姓名:"+ newemp.name+ "
"); document.write("雇员代号:"+ newemp.code +"
"); 输出的结果是().
A.雇员姓名:wangli 雇员代码:A001
B.雇员姓名:zhangming 雇员代码:A002
C.雇员姓名:null, 雇员代码:null
D.代码有错误,无输出结果

我来回答:

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

订单号:

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