网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
单选题
10. public class Hello {  11. String title;  12. int value;  13. public Hello() {  14. title += “ World”;  15. }  16. public Hello(int value) {  17. this.value = value;  18. title = “Hello”;  19. Hello();  20. }  21. }  and:  30. Hello c = new Hello(5);  31. System.out.println(c.title);  What is the result?()
A

 Hello

B

 Hello World

C

 Compilation fails.

D

 Hello World 5

E

 The code runs with no output.

F

 An exception is thrown at runtime.


参考答案

参考解析
解析: 暂无解析
更多 “单选题10. public class Hello {  11. String title;  12. int value;  13. public Hello() {  14. title += “ World”;  15. }  16. public Hello(int value) {  17. this.value = value;  18. title = “Hello”;  19. Hello();  20. }  21. }  and:  30. Hello c = new Hello(5);  31. System.out.println(c.title);  What is the result?()A  HelloB  Hello WorldC  Compilation fails.D  Hello World 5E  The code runs with no output.F  An exception is thrown at runtime.” 相关考题
考题 下面程序创建了一个线程并运行,请填空,使程序完整。public class ThreadTest {public static void main (String[] args) {Hello h=Hew Hello ();【 】t.start ();}}class Hello implements Runnable {int i;public void run () {while(true) {System.out.println("Hello" +i++);if(i==5) break;}}}

考题 package test;class Target{public String name=hello;}What can directly access and change the value of the variable name?() A.any classB.only the Target classC.any class in the test packageD.any class that extends Target

考题 10. public class ClassA {  11. public void count(int i) {  12. count(++i);  13. }  14. }  And:  20. ClassA a = new ClassA();  21. a.count(3);  Which exception or error should be thrown by the virtual machine?() A、 StackOverflowErrorB、 NullPointerExceptionC、 NumberFormatExceptionD、 IllegalArgumentExceptionE、 ExceptionlnlnitializerError

考题 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.

考题 Class TestException  1. public class TestException extends Exception {  2. } Class a:  1. public class a {  2.  3. public String sayHello(String name) throws TestException {  4.  5. if(name == null) {  6. throw new TestException();  7. }  8.  9. return “Hello “+ name;  10. }  11.  12. }  A programmer wants to use this code in an application: 45. A a=new A();  46. System.out.println(a.sayHello(”John”));  Which two are true?()A、 Class a will not compile.B、 Line 46 can throw the unchecked exception TestException.C、 Line 45 can throw the unchecked exception TestException.D、 Line 46 will compile if the enclosing method throws a TestException.E、 Line 46 will compile if enclosed in a try block, where TestException is caught.

考题 class Super {  public int i = 0;  public Super(String text) {  i = 1; }  }  public class Sub extends Super {  public Sub(String text) {  i = 2;  }   public static void main(String args[]) {  Sub sub = new Sub(“Hello”);  System.out.println(sub.i);  }  }  What is the result?()  A、 0B、 1C、 2D、 Compilation fails.

考题 Assume that country is set for each class.  Given:  10. public class Money {  11. private String country, name;  12. public getCountry() { return country; }  13.}  and:  24. class Yen extends Money {  25. public String getCountry() { return super.country; }  26. }  27.  28. class Euro extends Money {  29. public String getCountry(String timeZone) {  30. return super.getCountry();  31. }  32. }  Which two are correct?()A、 Yen returns correct values.B、 Euro returns correct values.C、 An exception is thrown at runtime.D、 Yen and Euro both return correct values.E、 Compilation fails because of an error at line 25.F、 Compilation fails because of an error at line 30.

考题 10. public class Hello {  11. String title;  12. int value;  13. public Hello() {  14. title += “ World”;  15. }  16. public Hello(int value) {  17. this.value = value;  18. title = “Hello”;  19. Hello();  20. }  21. }  and:  30. Hello c = new Hello(5);  31. System.out.println(c.title);  What is the result?() A、 HelloB、 Hello WorldC、 Compilation fails.D、 Hello World 5E、 The code runs with no output.F、 An exception is thrown at runtime.

考题 1. public class test (  2. public static void main(string args[]) {  3. int 1= 0;  4. while (i)  {  5. if (i==4) {  6. break;  7. }  8. ++i;  9. }  10.    11. }  12. )   What is the value of i at line 10?()A、 0B、 3C、 4D、 5E、 The code will not compile.

考题 1. public class A {  2.  3. private int counter = 0;  4.  5. public static int getInstanceCount() {  6. return counter;  7. }  8.  9. public A() {  10. counter++;  11. }  12.  13. }  Given this code from Class B:  25.A a1 =new A();  26. A a2 =new A();  27. A a3 =new A();  28. System.out.printIn(A.getInstanceCount() ); What is the result?() A、 Compilation of class A fails.B、 Line 28 prints the value 3 to System.out.C、 Line 28 prints the value 1 to System.out.D、 A runtime error occurs when line 25 executes.E、 Compilation fails because of an error on line 28.

考题 单选题1. class A {  2. public String toString ()  {  3. return “4”;  4. }  5. }  6. class B extends A {  7. public String toString ()   {  8. return super.toString()  + “3”;  9. }  10. }  11. public class Test {  12.   public static void main(String[]args)  {  13.      System.out.printIn(new B());  14.      }  15. }    What is the result?()A  Compilation succeeds and 4 is printed.B  Compilation succeeds and 43 is printed.C  An error on line 9 causes compilation to fail.D  An error on line 14 causes compilation to fail.E  Compilation succeeds but an exception is thrown at line 9.

考题 多选题Class TestException  1. public class TestException extends Exception {  2. } Class a:  1. public class a {  2.  3. public String sayHello(String name) throws TestException {  4.  5. if(name == null) {  6. throw new TestException();  7. }  8.  9. return “Hello “+ name;  10. }  11.  12. }  A programmer wants to use this code in an application: 45. A a=new A();  46. System.out.println(a.sayHello(”John”));  Which two are true?()AClass a will not compile.BLine 46 can throw the unchecked exception TestException.CLine 45 can throw the unchecked exception TestException.DLine 46 will compile if the enclosing method throws a TestException.ELine 46 will compile if enclosed in a try block, where TestException is caught.

考题 单选题class Super {  public int i = 0;  public Super(String text) {  i = 1; }  }  public class Sub extends Super {  public Sub(String text) {  i = 2;  }   public static void main(String args[]) {  Sub sub = new Sub(“Hello”);  System.out.println(sub.i);  }  }  What is the result?()A  0B  1C  2D  Compilation fails.

考题 单选题1. public class A {  2.  3. private int counter = 0;  4.  5. public static int getInstanceCount() {  6. return counter;  7. }  8.  9. public A() {  10. counter++;  11. }  12.  13. }  Given this code from Class B:  25.A a1 =new A();  26. A a2 =new A();  27. A a3 =new A();  28. System.out.printIn(A.getInstanceCount() ); What is the result?()A  Compilation of class A fails.B  Line 28 prints the value 3 to System.out.C  Line 28 prints the value 1 to System.out.D  A runtime error occurs when line 25 executes.E  Compilation fails because of an error on line 28.

考题 单选题10. interface Foo { int bar(); }  11. public class Sprite {  12. public int fubar( Foo foo) { return foo.bar(); }  13. public void testFoo() {  14. fubar(  15. // insert code here  16.);  17. }  18. }  Which code, inserted at line 15, allows the class Sprite to compile?()A  Foo { public int bar() { return 1; } }B  new Foo { public int bar() { return 1; } }C  newFoo() { public int bar(){return 1; } }D  new class Foo { public int bar() { return 1; } }

考题 单选题1. class A {  3. public String to String() {  4. return “4”;  5. }  6. }  7. class B extends A {  8. public String toString() { 9. return super.toString() + “3”;  10. }  11. }  12. public class Test {  13. public static void main (String[] args) {  14. System.out.printIn(new B()); 15. }  16. }   What is the result( )?A  Compilation succeeds and 4 is printed.B  Compilation …………… is printed.C  An error on line 9 cause compilation to fail.D  An error on line 14 cause compilation to fail.E  Compilation succeeds but an exception is thrown at line 9.

考题 单选题A programmer is designing a class to encapsulate the information about an inventory item. A JavaBeans component is needed to do this. The Inventoryltem class has private instance variables to store the item information:  10. private int itemId;  11. private String name;  12. private String description;  Which method signature follows the JavaBeans naming standards for modifying the itemld instance variable?()A  itemID(int itemId)B  update(int itemId)C  setItemId(int itemId)D  mutateItemId(int itemId)E  updateItemID(int itemId)

考题 单选题1. public class SimpleCalc {  2. public int value;  3. public void calculate() { value += 7; }  4. } And:  1. public class MultiCalc extends SimpleCalc {  2. public void calculate() { value -= 3; }  3. public void calculate(int multiplier) {  4. calculate();  5. super.calculate();  6. value *=multiplier;  7. }  8. public static void main(String[] args) {  9. MultiCalc calculator = new MultiCalc();  10. calculator.calculate(2);  11. System.out.println(”Value is: “+ calculator.value);  12. }  13. }  What is the result?()A  Value is: 8B  Compilation fails.C  Value is: 12D  Value is: -12E  The code runs with no output.F  An exception is thrown at runtime.

考题 单选题package test; class Target{ public String name="hello"; } What can directly access and change the value of the variable name?()A any classB only the Target classC any class in the test packageD any class that extends Target

考题 单选题1. class A {  2. public int getNumber(int a) {  3.     return a + 1;  4. }  5. }  6.    7. class B extends A {  8. public int getNumber (int a) {  9. return a + 2  10. }  11.    12. public static void main (String args[])  {  13. A a = new B();  14. System.out.printIn(a.getNumber(0));  15.    } 16. }     What is the result?()A  Compilation succeeds and 1 is printed.B  Compilation succeeds and 2 is printed.C  An error at line 8 causes compilation to fail.D  An error at line 13 causes compilation to fail.E  An error at line 14 causes compilation to fail.

考题 单选题10. public class ClassA {  11. public void count(int i) {  12. count(++i);  13. }  14. }  And:  20. ClassA a = new ClassA();  21. a.count(3);  Which exception or error should be thrown by the virtual machine?()A  StackOverflowErrorB  NullPointerExceptionC  NumberFormatExceptionD  IllegalArgumentExceptionE  ExceptionlnlnitializerError

考题 单选题1. public class SwitchTest {  2. public static void main (String []args)  {  3. System.out.PrintIn(“value =” +switchIt(4));  4. }  5. public static int switchIt(int x)  {  6. int j = 1;  7. switch (x) {  8. case 1: j++;  9. case 2: j++;  10. case 3: j++;  11. case 4: j++;  12. case 5: j++;  13. default:j++;  14. }  15. return j + x;  16. }  17. }     What is the output from line 3?()A  Value = 3B  Value = 4C  Value = 5D  Value = 6E  Value = 7F  Value = 8

考题 单选题1. public class test (  2. public static void main(string args[]) {  3. int 1= 0;  4. while (i)  {  5. if (i==4) {  6. break;  7. }  8. ++i;  9. }  10.    11. }  12. )   What is the value of i at line 10?()A  0B  3C  4D  5E  The code will not compile.

考题 单选题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. public class ClassA {  11. public void methodA() {  12. ClassB classB = new ClassB();  13. classB.getValue();  14. }  15. }  And:  20. class ClassB {  21. public ClassC classC;  22.  23. public String getValue() {  24. return classC.getValue();  25. }  26. }  And:  30. class ClassC {  31. public String value;  32.  33. public String getValue() {  34. value = “ClassB”;  35. return value;  36. }  37. }  Given:  ClassA a = new ClassA();  a.methodA();  What is the result?()A  Compilation fails.B  ClassC is displayed.C  The code runs with no output.D  An exception is thrown at runtime.

考题 单选题package test;  class Target {  public String name = “hello”;  }  What can directly access and change the value of the variable name?()A  any classB  only the Target classC  any class in the test packageD  any class that extends Target

考题 填空题1. public class test {  2. public static string output = “”  3.    4. public static void foo(int i) {  5. try {  6. if(i= =1) {  7. throw new Exception ();  8. }  9. output += “1”;  10.}  11. catch(Exception e)  {  12. output += “2”;  13. return;  14.}  15. finally (  16. output += “3”;  17. )  18. output += “4”;  19. } 20.    21. public static void main (string args[])  (  22. foo(0);  23. foo(1);  24.    25. )  26. } What is the value of the variable output at line 24?()

考题 多选题11. public interface Status {  12. /* insert code here */ int MY_VALUE = 10;  13. }  Which three are valid on line 12?()AfinalBstaticCnativeDpublicEprivateFabstractGprotected