首页 > 考试题库
题目内容 (请给出正确答案)
[单选题]

分析下列程序:public class class4{private string _sData = "";public string sData{set{_sData = value;}}}在Main 函数中,在成功创建该类的对象obj 后,下列哪些语句是合法的?()

A.obj.sData = "It is funny!";

B.Consol

C.WriteLine(obj.sData);

D.obj._sData = 100;

E.obj.set(obj.sData);

查看答案
答案
收藏
如果结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能还需要:
您的账号:
发送账号密码至手机
发送
安装优题宝APP,拍照搜题省时又省心!
更多“分析下列程序:public class class4{pri…”相关的问题
第1题
有以下程序片段,下列哪个选项不能插入到行1。()1.2 .public class Interesting{undefined3. //do sth4.}

A.import jav

B.awt.

C.package mypackage

D.class OtherClass{ }

E.public class MyClass{ }

点击查看答案
第2题
关于下列程序段的输出结果,说法正确的是:()public class MyClass{static int i;public static v

A.有错误,变量i没有初始化。

B.null

C.1

D.0

点击查看答案
第3题
程序运行的结果是:_______________。 public class Example{ String str=new String("good");

程序运行的结果是:_______________。

public class Example{

String str=new String("good");

char[]ch={'a','b','c'};

public static void main(String args[]){

Example ex=new Example();

ex.change(ex.str,ex.ch);

System.out.print(ex.str+" and ");

Sytem.out.print(ex.ch);

}

public void change(String str,char ch[]){

str="test ok";

ch[0]='g';

}

}

点击查看答案
第4题
分析一下这段程序的输出 (Autodesk) class B { public: B() { cout<<"default construc

分析一下这段程序的输出 (Autodesk)

class B

{

public:

B()

{

cout<<"default constructor"<}

~B()

{

cout<<"destructed"<}

B(int i):data(i) //B(int) works as a converter (int -> instance of B)

{

cout<<"constructed by parameter " << data <}

private:

int data;

};

B Play(B b)

{

return b ;

}

点击查看答案
第5题
程序阅读:public class test{public static void main(String argv[]){boolean b1 = true;if((

程序阅读:public class test

{

public static void main(String argv[])

{

boolean b1 = true;

if((b1 ==true) || place(true))

{

System.out.println("Hello Crowle");

}

}

public static boolean place(boolean location)

{

if(location==true)

{

System.out.println("Borcetshire");

}

System.out.println("Powick");

return true;

}

}

点击查看答案
第6题
输出下面程序结果。#i nclude <iostream.h>class A{public:virtual void print(void){co

输出下面程序结果。

#i nclude <iostream.h>

class A

{

public:

virtual void print(void)

{

cout<<"A::print()"<<endl;

}

};

class B:public A

{

public:

virtual void print(void)

{

cout<<"B::print()"<<endl;

};

};

class C:public B

{

public:

virtual void print(void)

{

cout<<"C::print()"<<endl;

}

};

void print(A a)

{

a.print();

}

void main(void)

{

A a, *pa,*pb,*pc;

B b;

C c;

pa=&a;

pb=&b;

pc=&c;

a.print();

b.print();

c.print();

pa->print();

pb->print();

pc->print();

print(a);

print(b);

print(c);

}

A:

A::print()

B::print()

C::print()

A::print()

B::print()

C::print()

A::print()

A::print()

A::print()

点击查看答案
第7题
阅读下列程序,请写出程序的运行结果。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){}

}

}

}

}

点击查看答案
第8题
分析一下这段程序的输出(Autodesk)class B{public:B(){cout<<"default constructor"&l

分析一下这段程序的输出(Autodesk)

class B

{

public:

B()

{

cout<<"default constructor"<<endl;

}

~B()

{

cout<<"destructed"<<endl;

}

B(int i):data(i) //B(int) works as a converter (int ->

instance of B)

{

cout<<"constructed by parameter " << data <<endl;

}

private:

int data;

};

B Play(B b)

{

return b ;

}

点击查看答案
第9题
阅读下面程序,写出输出结果。#include using namespace std ; class A { int a, b; public :
阅读下面程序,写出输出结果。#include using namespace std ; class A { int a, b; public :

阅读下面程序,写出输出结果。

#include using namespace std ; class A { int a, b; public : A() { a = b = 0; }

A(int aa, int bb) { a = aa; b = bb; cout << a << ' ' << b << endl ; } }; int main() { A x, y(2,3);

return 0; }

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

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);

}

}

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