首页 > 计算机等级考试
题目内容 (请给出正确答案)
[主观题]

检查如下代码:public class Quiz2_l{public static void main(String[] args) {int a = 8;int

检查如下代码:

public class Quiz2_l{

public static void main(String[] args) {

int a = 8;

int b = -8;

System.out.print(a<< 2、;

System.out.print("," + (b>>1、 );

}

}

下列哪条语句正确描述了程序在编译和运行时的行为?

A.编译成功,输出为“32,-4 ”

B. 编译成功,输出为“16,4 ”

C. 编译成功,输出为“32,2147483644”

D. 编译成功,输出为“16,2147483644”

E. 编泽器拒绝表达式 b>>,因为不能对一个负数应用>>操作符

查看答案
答案
收藏
如果结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能还需要:
您的账号:
发送账号密码至手机
发送
安装优题宝APP,拍照搜题省时又省心!
更多“检查如下代码:public class Quiz2_l{pu…”相关的问题
第1题
已知如下代码:public class Test{long a[]=newlong[10]:public static void main(String arg[]){

已知如下代码: public class Test { long a[]=newlong[10]: public static void main(String arg[]){ System.out.println(a[6]): } } 请问哪个语句是正确的()。

A.输出为null

B.输出为0

C.编译时出错

D.运行时出错

点击查看答案
第2题
阅读如下代码:public class X5_3_3 extends Hide {int x = 200;public static void main(Stri

A.100

B.200

C.程序错误

D.300

点击查看答案
第3题
设有如下代码:interface IFace{}class CFace implements IFace{}class Base{}public class Ob

设有如下代码:

interface IFace{}

class CFace implements IFace{}

class Base{}

public class ObRef extends Base{

public static void main(String argv[]){

ObRef bj = new ObRef();

Base b = new Base();

Object obj1 = new Object();

IFace obj2 = new CFace();

//Here

}

}

则在 //Here处插入哪个代码将不出现编译和运行错误。

A.obj1=obj2;

B.b=obj;

C.obj=b;

D.obj1=b;

点击查看答案
第4题
考虑如下代码:class Tree{}class Pine extends Tree{}class Oak extends Tree{}public class F

考虑如下代码:

class Tree{}

class Pine extends Tree{}

class Oak extends Tree{}

public class Forest {

public static void main(String[] args ) {

Tree tree = new Pine();

if(tree instanceof Pine )

System.out.println("Pine" );

if(tree instanceof Tree )

System.out.println("Tree" );

if(tree instanceof Oak )

System.out.println("Oak" );

else

System.out.println("Oops" );

}

}

则输出结果中有哪些?

A.Pine B.Tree C.Forest D.Oops E.无输出

点击查看答案
第5题
设有如下代码:class Base{}public class MyCast extends Base{static boolean b1=false;stat

设有如下代码:

class Base{}

public class MyCast extends Base{

static boolean b1=false;

static int i = -1;

static double d = 10.1;

public static void main(String argv[]){

MyCast m = new MyCast();

Base b = new Base();

//Here

}

}

则在 //Here处插入哪个代码将不出现编译和运行错误。

A.b=m;

B.m=b;

C.d =i;

D.b1 =i;

点击查看答案
第6题
如下代码创建一个新线程并启动线程: Runnable target=new MyRunnable(); Thread myThread=new Thread(target); 问:如 些类可以创建target对象,并能编译正确

A.public class MyRunnable extends Runnable { public void run(){} }

B.public class MyRunnable extends Object { public void run(){} }

C.public class MyRunnable implements Runnable {public void run(){}}

D.public class MyRunnable implements Runnable {void run(){}}

点击查看答案
第7题
以下代码的运行结果为:public class Calc {public static void main (String args []) {int to

以下代码的运行结果为:

public class Calc {

public static void main (String args []) {

int total = 0;

for (int i = 0, j = 10; total >30; ++i, --j) {

System.out.println(" i = " + i + " : j = " + j);

total += (i + j);

}

System.out.println("Total " + total);

}

}

A. 产生运行错误

B. 产生编译错误

C. 输出 "Total 0"

D. 产生如下输出:

i = 0 : j = 10

i = 1 : j = 9

i = 2 : j = 8

Total 30

点击查看答案
第8题
有类的定义如下: class A{ private: int x,y; public: A(int m,int n){x=m;y=n;} }; Class B{ private: int z; A a; public: B(int m); }; 下列()是正确的B类构造函数实现代码。

A.B::B(int m) : a(m), z(m){ }

B.B::B(int m) : a(),z() { }

C.B::B(int m) : a(m,m), z(m){ }

D.B::B(int m) : a=(m,m), z=m { }

点击查看答案
第9题
设有如下类class Loop{public static void main(String[] agrs) {int x=0;int y=0;outer:for(x

设有如下类

class Loop{

public static void main(String[] agrs) {

int x=0;int y=0;

outer:

for(x=0;x<100;x++){

middle:

for(y=0;y<100;y++){

System.out.println("x="+x+"; y="+y);

if(y==10){<<>>}

}

}

}

}

在<<>>处插入什么代码可以结束外循环?

A.continue middle;

B.break outer;

C.break middle;

D.continue outer;

E.none of these

点击查看答案
第10题
下面的程序是用do-while语句计算10的阶乘。请在程序的每条横线处填写1个语句,使程序的功能完整。

注意:请勿改动main()主方法和其他已有的语句内容;仅在横线处填入适当的语句。

源程序文件代码清单如下:

public class DoWhileLoop

{

public static void main(______)

{

int n=10;

long result=1;

do

{

_____;

}

_____;

System.out.println("10的阶乘为:"+result);

}

}

点击查看答案
退出 登录/注册
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改