首页 > 建筑规划> 注册建筑师
题目内容 (请给出正确答案)
[主观题]

以下程序的编译和运行结果为?class test {static boolean check;public static void main(String args[]) {int i;if(check == true)i=1;elsei=2;if(i= 2、i=i+2;else i = i + 4;System.out.println(i);}}

A. 3

B. 4

C. 5

D. 6

E. 语句if(i= 2、编译出错

查看答案
答案
收藏
如果结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能还需要:
您的账号:
发送账号密码至手机
发送
安装优题宝APP,拍照搜题省时又省心!
更多“以下程序的编译和运行结果为?class test {stat…”相关的问题
第1题
以下的程序的调试结果为?public class MyAr{public static void main(String argv[]) {MyAr m = new MyAr();m.amethod();}public void amethod(){static int i;System.out.println(i);}}

A. 输出结果为 0

B. 运行出错

C. 输出结果为 null

D. 编译错误

点击查看答案
第2题
以下的程序的调试结果为?public class As{int i = 10;int j;char z= 1;boolean b;public static

以下的程序的调试结果为?

public class As{

int i = 10;

int j;

char z= 1;

boolean b;

public static void main(String argv[]){

As a = new As();

A.amethod();

}

public void amethod(){

System.out.println(j);

System.out.println(b);

}

}

A.输出0 和false

B. 输出0 和true

C. 编译错误,b 未初始化

D. 编译错误, z 必须赋字符值

点击查看答案
第3题
下面程序的运行结果是()public class demo {public static void main(string[] args) {try {

A.编译失败

B.编译通过,没有结果输出

C.输出:除法正常运行

D.输出:除数不能为0

点击查看答案
第4题
下面代码运行后的输出结果为()。public class X6_1_5 {public static void main(String[] args)

A.equals(aa));}}class AB{ int x = 100; }

B.true

C.false

D.编译错误

E.100

点击查看答案
第5题
以下程序的运行结果为:public class A {static int k=3;public static void main(String[] args) {int k=4;A x1=new A();x1.k++;A x2=new A();x2.k++;k++;System.out.println(x1.k);}}

A. 3

B. 4

C.5

D.6

E.7

点击查看答案
第6题
写出以下程序的运行结果

class A

{

int a;

A(int b)

{a=b;}

void show()

{System.out.println(“a=”+a);}

}

public class Class1

{

public static void main (String args[])

{

A bj=new A(12345);

boolean b=false;

char ch=97;

obj.show();

System.out.println(“b=”+b+”/tch=”+ch);

}

}

点击查看答案
第7题
给出下面代码,关于该程序以下哪个说法是正确的()?public class Person static in tarr=new
给出下面代码,关于该程序以下哪个说法是正确的()?public class Person static in tarr=new

给出下面代码,关于该程序以下哪个说法是正确的()?public class Person static in tarr=new int5;public static void main(Stringa)System.out.println(arr0);

A.编译时将产生错误

B.编译时正确,运行时将产生错误

C.输出零

D.输出空

点击查看答案
第8题
下面程序的运行结果为()。#include<iostream.h>class A{int numpublic:A(int i){num=i;}A(A&a

下面程序的运行结果为()。 #include<iostream.h> class A { int num public: A(int i){num=i;} A(A&a){Bum=a.num++;} void print(){cout<<Bum;} }; void main() { A a(1),b(a); A. print(); B.print(); }

A.11

B.12

C.21

D.22

点击查看答案
第9题
阅读下列程序,请写出程序的运行结果。import java.applet.*;import java.awt.*;public class C

阅读下列程序,请写出程序的运行结果。

import java.applet.*;

import java.awt.*;

public class C extends Applet implements Runnable

{

Thread redBall,blueBall;

Graphics redPen,bluePen;

int blueSeta=0,redSeta=0;

public void init()

{

setSize(250,200);

redBall=new Thread(this);

blueBall=new Thread(this);

redPen=getGraphics();

bluePen=getGraphics();

redPen.setColor(Color.red);

bluePen.setColor(Color.blue);

setBackground(Color.gray);

}

public void start()

{

redBall.start();

blueBall.start();

}

public void run()

{

intx,y;

while(true)

{

if(Thread.currentThread()==redBall)

{//以下代码为顺时针画圆

x=(int)(80.0*Math.cos(3.1415926/180.0*redSeta));

y=(int)(80.0*Math.sin(3.1415926/180.0*redSeta));

redPen.setColor(Color.gray);

redPen.fillOval(100+x,100+y,10,10);

redSeta+=3;

if(redSeta>=360)redSeta=0;

x=(int)(80.0*Math.cos(3.1415926/180.0*redSeta));

y=(int)(80.0*Math.sin(3.1415926/180.0*redSeta));

redPen.setColor(Color.red);

redPen.fillOval(100+x,100+y,10,10);

try{redBall.sleep(20);}

catch(InterruptedException e){}

}

elseif(Thread.currentThread()==blueBall)

{//以下代码为顺时针画圆

x=(int)(80.0*Math.cos(3.1415926/180.0*blueSeta));

y=(int)(80.0*Math.sin(3.1415926/180.0*blueSeta));

bluePen.setColor(Color.gray);

bluePen.fillOval(150+x,100+y,10,10);

blueSeta-=3;

if(blueSeta<=-360)blueSeta=0;

x=(int)(80.0*Math.cos(3.1415926/180.0*blueSeta));

y=(int)(80.0*Math.sin(3.1415926/180.0*blueSeta));

bluePen.setColor(Color.blue);

bluePen.fillOval(150+x,100+y,10;10);

try{blueBall.sleepp(40);}

catch(InterruptedException e){}

}

}

}

}

点击查看答案
第10题
有以下程序:#include <iostream>using namespace std;class Base{public:Base(){}virtual void w

有以下程序: #include <iostream> using namespace std; class Base { public: Base(){} virtual void who() { cout<<"Base Class"<<end1; } ~Base(){} }; class Derivel : public Base { public: void who() { cout<<"Derivel Class"<<end1; } }; class Derive2 : public Base { public: void who () { cout<<"Derive2 Class"<<end1; } }; int main () { Base *p; Derivel obj1; Derive2 obj2; p=&obj1; p=&obj2; p->who (); return 0; } 执行程序后的输出结果是()。

A.Base Class

B.Derivel Class

C.Derive2 Class

D.程序编译时出错

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