publicclassClassA{publicintgetValue(){intvalue=0;booleansetting=true;Stringtitle=”Hello”;(value||(settingtitle==Hello”)){return1;}(value==1title.equals(”Hello”)){return2;}}}And:ClassAa=newClassA();a.getValue();Whatistheresult?()A.1B.2C.Compilationfails.D.Thecoderunswithnooutput.E.Anexceptionisthrownatruntime.
publicclassClassA{publicintgetValue(){intvalue=0;booleansetting=true;Stringtitle=”Hello”;(value||(setting&&title==Hello”)){return1;}(value==1&title.equals(”Hello”)){return2;}}}And:ClassAa=newClassA();a.getValue();Whatistheresult?()
A.1
B.2
C.Compilationfails.
D.Thecoderunswithnooutput.
E.Anexceptionisthrownatruntime.
相关考题:
下面程序的功能是创建一个显示5个“Hello!”的线程并启动运行。请将程序补充完整。public class ThreadTest extends Thread {public static void main(String args[]) {ThreadTest t=new ______;t.start();}public void run() {int i=0;while(true) {System.out.println("Hello!");if(i++==4)break;}}}
public class ClassA{public int getValue(){int value=0;boolean setting=true;String title=Hello;if(value||(setting title==Hello)){return 1;}if(value==1title.equals(Hello)){return 2;}}}And:ClassA a=new ClassA();a.getValue();What is the result?()A.1B.2C.Compilation fails.D.The code runs with no output.E.An exception is thrown at runtime.
10.publicclassHello{11.Stringtitle;12.intvalue;13.publicHello(){14.title+=World”;15.}16.publicHello(intvalue){17.this.value=value;18.title=Hello”;19.Hello();20.}21.}and:30.Helloc=newHello(5);31.System.out.println(c.title);Whatistheresult?()A.HelloB.HelloWorldC.Compilationfails.D.HelloWorld5E.Thecoderunswithnooutput.F.Anexceptionisthrownatruntime.
下列程序的功能是创建一个显示5个“Hello!”的线程并启动运行,试将程序补充完整。public class ThreadTest extends Thread{public static void main(String args[ ]){ThreadTest t=new______;t.start( );}public void run( ){int i=0;while(true){System.out.println("Hello!");if(i++==4)break;}}
下列程序段的输出是( )。 public class Test { public static void main (String args[ ]) { String ss1 = new String("hello"); String ss2 = new String("hello"); System.out.println(ssl == ss2); System.out.println (ssequals(ss2)); } }A.true, falseB.true, trueC.false, trueD.false, false
以下变量初始化语句中,正确的有 ()A.boolean flag = true;B.int i = 32;C.float r = 10.0;D.double pi = 3.1415926;E.int value = 32.0;
为了向文件hello.txt尾部追加数据,下列哪个是正确创建指向hello.txt的流()A.try{ OutputStream out=new FileOutputStream("hello.txt"); }catch(IOException e) { }B.try{ OutputStream out=new FileOutputStream("hello.txt",true); }catch(IOException e) { }C.try{ OutputStream out=new FileOutputStream("hello.txt",false); }catch(IOException e) { }D.try{ OutputStream out=new OutputStream("hello.txt",true); }catch(IOException e) { }