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

题目内容 (请给出正确答案)

在Java中,下列代码将输出()。  1.    public class integerequals  2.    {  3.       public static void main (String args[])  4. {  5.  Integer a= new Integer(3);  6.  Integer b= new Integer(3);  7.   System.out.println(a==b);  8. }  9.    } 

  • A、编译器将显示第7行有错误
  • B、程序编译并打印true
  • C、程序编译并打印false
  • D、程序编译但在第7行引起了一个运行期意外

参考答案

更多 “ 在Java中,下列代码将输出()。  1.    public class integerequals  2.    {  3.       public static void main (String args[])  4. {  5.  Integer a= new Integer(3);  6.  Integer b= new Integer(3);  7.   System.out.println(a==b);  8. }  9.    } A、编译器将显示第7行有错误B、程序编译并打印trueC、程序编译并打印falseD、程序编译但在第7行引起了一个运行期意外” 相关考题
考题 本题中,用表格表现某个月的月历,其中标题是从Sunday到Saturday,表格中的各项是可以修改的。 import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.table.*; public class java2 ( public static void main(String[]args) { try{ UIManager.setLookAndFeel(UIManager.getSys- temLookAndFeelClassName): } catch(Exception e) JFrame. frame=new CalendarTableFrame; frame.setDefaultCloseOperation(JFrame.EXIT_ oN CLOSE); frame.show; } } clasgCalendarTableFrame. extends JFrame { private static final int WIDTH=500; private static final int HEIGHT=150: private cells= { {null,null,null,new Integer(1),new Integer (2),new Integer(3),new Integer(4)), {new Integer(5),new Integer(6),new Integer (7).new Integer(8),new Integer(9),new Integer (10),new Integer(11)), {new Integer(12),new Integer(13),new Integer (14),new Integer(15),new Integer(16),new Integer (17),new Integer(18)), {new Integer(19),new Integer(20),new Integer (21),new Integer(22),new Integer(23),new Integer (24),new Integer(25)), {new Integer(26),new Integer(27),new Integer (28),new Integer(29),new Integer(30),new Integer (31),null} }; private String[]columnNames={ "Sunday","Monday","Tuesday","Wednesday", "Thursday","Friday","Saturday" }; public CalendarTableFrame{ setTitle("java2"); setSize(WIDTH,HEIGHT); JTable table=new ; getContentPane.add(new JScrollPane(table), BorderLayout.CENTER); } }

考题 下列程序中,实现将封装数据类型Integer和基本数据类型int之间的转换,以及Integer,int类型和String类型之间的转换。请将程序补充完整。程序运行结果如下:123456456public class ex7_1{public static void main(String[]args) {Integer intObj;int n;String s;intObj = new Integer(123);n=intObj.__________;System.out.printin(Integer.toString(n));s=new String("456");intObj=Integer._________;System.out.println(intObj.__________);n=Integer.parseInt(s);System.out.println(Integer.toString(n));}}

考题 public static void main(String[]args){Integer i=new Integer(1)+new Integer(2);switch(i){case3:System.out.println(three);break;default:System.out.println(other);break;}}Whatistheresult?()A.threeB.otherC.Anexceptionisthrownatruntime.D.Compilationfailsbecauseofanerroronline12.E.Compilationfailsbecauseofanerroronline13.F.Compilationfailsbecauseofanerroronline15.

考题 编译和运行以下代码结果为:1. public class EqualsTest{2. public static void main(String args[]){3. byte A=(byte)4096;4. if(A== 4096、System.out.println("Equal");5. else System.out.println("Not Equal");6. }7. }A.在第3行出现转换丢失精度的编译错误.B.输出 "Not Equal".C.输出 "Equal".

考题  class Super {  public Integer getLenght() { return new Integer(4); } }  public class Sub extends Super {  public Long GetLenght() { return new Long(5); }  public static void main(String[] args) { Super sooper = new Super();  Sub sub = new Sub();  System.out.println(  sooper.getLenght().toString() + “,” +  sub.getLenght().toString() ); } }  What is the output?()  A、 4,4B、 4,5C、 5,4D、 5,5E、 Compilation fails.

考题 public class Test {  public static void add3 (Integer i) {  int val = i.intValue();  val += 3;  i = new Integer(val); }  public static void main(String args[]) {  Integer i = new Integer(0);  add3(i);  System.out.println(i.intValue());  }  }   What is the result? () A、 0B、 3C、 Compilation fails.D、 An exception is thrown at runtime.

考题 1. public class Outer{  2. public void someOuterMethod() {  3. // Line 3  4. }  5. public class Inner{}  6. public static void main( String[]argv ) {  7. Outer o = new Outer();  8. // Line 8  9. }  10. }  Which instantiates an instance of Inner?()  A、 new Inner(); // At line 3B、 new Inner(); // At line 8C、 new o.Inner(); // At line 8D、 new Outer.Inner(); // At line 8

考题 class Beta {  public static void main(String [] args) {  Integer x = new Integer(6) * 7;  if (x != 42) {  System.out.print("42 ");  } else if (x 〈 new Integer(44-1)) {  System.out.println("less");  } else {  System.out.print("done"); } } }  结果是什么?() A、lessB、42C、doneD、编译失败

考题 1. public class Target {  2. private int i = 0;  3. public int addOne() {  4. return ++i;  5. }  6. }  And:  1. public class Client {  2. public static void main(String[] args) {  3. System.out.println(new Target().addOne());  4. }  5. }  Which change can you make to Target without affecting Client?() A、 Line 4 of class Target can be changed to return i++;B、 Line 2 of class Target can be changed to private int i = 1;C、 Line 3 of class Target can be changed to private int addOne() {D、 Line 2 of class Target can be changed to private Integer i = 0;

考题 1. public class A {  2. void A() {  3. System.out.println(“Class A”);  4. }  5. public static void main(String[] args) {  6. new A();  7. }  8. }  What is the result?()  A、 Class AB、 Compilation fails.C、 An exception is thrown at line 2.D、 An exception is thrown at line 6.E、 The code executes with no output.

考题 现有:   1.  class HorseRadish {   2.    // insert code here   3.    protected HorseRadish(int x) {    4.      System.out.println("bok choy");  5.    }  6.  }   7.  class Wasabi extends HorseRadish {   8.    public static void main(String [] args) {   9.      Wasabi w = new Wasabi();  10.   }    11. }   分别插入到第 2 行,哪两项允许代码编译并产生"bok choy" 输出结果?() A、 // just a commentB、 protected HorseRadish() { }C、 protected HorseRadish() { this(42);}D、 protected  HorseRadish() { new HorseRadish (42);}

考题 public static void main( String[] args ) {  Integer a = new Integer(10);  Integer b = new Integer(10);  Integer c = a;  int d = 10;  double e = 10.0;  }   Which three evaluate to true?()   A、 (a == c)B、 (d == e)C、 (b == d)D、 (a == b)E、 (b == c)F、 (d == 10.0)

考题 1. class Calc {  2. public static void main(String [] args) {  3. try {  4. int x = Integer.parseInt("42a");  5. //insert code here  6. System.out.print("oops ");  7. }  8. }  9. }  下面哪两行分别插入到第五行,会导致输出“oops”?()A、} catch (ClassCastException c) {B、} catch (IllegalStateException c) {C、} catch (NumberFormatException n) {D、} catch (IllegalArgumentException e) {

考题 1. public class Boxer1 {  2. Integer i;  3. int x;  4. public Boxer1(int y) {  5. x=i+y;  6. System.out.println(x);  7. }  8. public static void main(String[] args) {  9. new Boxer1(new Integer(4));  10. }  11. }  What is the result?() A、 The value “4” is printed at the command line.B、 Compilation fails because of an error in line 5.C、 Compilation fails because of an error in line 9.D、 A NullPointerException occurs at runtime.E、 A NumberFormatException occurs at runtime.F、 An IllegalStateException occurs at runtime.

考题 public static void main(String[]args){ Integer i=new Integer(1)+new Integer(2); switch(i){ case3:System.out.println("three");break; default:System.out.println("other");break; } } Whatistheresult?()A、threeB、otherC、Anexceptionisthrownatruntime.D、Compilationfailsbecauseofanerroronline12.E、Compilationfailsbecauseofanerroronline13.F、Compilationfailsbecauseofanerroronline15.

考题 1. import java.util.*;  2. public class Example {  3. public static void main(String[] args) {  4. // insert code here  5. set.add(new integer(2));  6. set.add(new integer(l));  7. System.out.println(set);  8. }  9. }  Which code, inserted at line 4, guarantees that this program will output [1,2]? ()A、 Set set = new TreeSet();B、 Set set = new HashSet();C、 Set set = new SortedSet();D、 List set = new SortedList();E、 Set set = new LinkedHashSet();

考题 1. public class enclosingone (  2. public class insideone{}  3. )  4. public class inertest(  5. public static void main (string[]args)(  6. enclosingone eo= new enclosingone ();  7. //insert code here  8. )  9. )    Which statement at line 7 constructs an instance of the inner class?()  A、 InsideOnew ei= eo.new InsideOn();B、 Eo.InsideOne ei = eo.new InsideOne();C、 InsideOne ei = EnclosingOne.new InsideOne();D、 EnclosingOne.InsideOne ei = eo.new InsideOne();

考题 public class test {   public static void add3 (Integer i){  int val = i.intValue ( );   val += 3;   i = new Integer (val);    }     public static void main (String args [ ] )  { Integer i = new Integer (0);    add3 (i);   system.out.printIn (i.intValue ( ) );   }    }   What is the result?()A、 Compilation will fail.B、 The program prints “0”.C、 The program prints “3”.D、 Compilation will succeed but an exception will be thrown at line 3.

考题 1. import java.util.*;  2.  3. Class FindStuff {  4. public static void  main(String [] args) {  5. // insert code here  6. c.put("x", 123);  7. }  8. } 分别插入到第5行,哪三行允许代码编译?() A、Map c = new SortedMap();B、HashMap c = new HashMap();C、HashMap c = new Hashtable();D、SortedMap c = new TreeMap();

考题 多选题public static void main( String[] args ) {  Integer a = new Integer(10);  Integer b = new Integer(10);  Integer c = a;  int d = 10;  double e = 10.0;  }   Which three evaluate to true?()A(a == c)B(d == e)C(b == d)D(a == b)E(b == c)F(d == 10.0)

考题 单选题public static void main(String[]args){ Integer i=new Integer(1)+new Integer(2); switch(i){ case3:System.out.println("three");break; default:System.out.println("other");break; } } Whatistheresult?()A threeB otherC Anexceptionisthrownatruntime.D Compilationfailsbecauseofanerroronline12.E Compilationfailsbecauseofanerroronline13.F Compilationfailsbecauseofanerroronline15.

考题 单选题1. import java.util.*;  2. public class Example {  3. public static void main(String[] args) {  4. // insert code here  5. set.add(new integer(2));  6. set.add(new integer(l));  7. System.out.println(set);  8. }  9. }  Which code, inserted at line 4, guarantees that this program will output [1,2]? ()A  Set set = new TreeSet();B  Set set = new HashSet();C  Set set = new SortedSet();D  List set = new SortedList();E  Set set = new LinkedHashSet();

考题 单选题在Java中,下列代码将输出()。  1.    public class integerequals  2.    {  3.       public static void main (String args[])  4. {  5.  Integer a= new Integer(3);  6.  Integer b= new Integer(3);  7.   System.out.println(a==b);  8. }  9.    }A 编译器将显示第7行有错误B 程序编译并打印trueC 程序编译并打印falseD 程序编译但在第7行引起了一个运行期意外

考题 单选题public class test {  public static void add3 (Integer i)  int val = i.intValue ( );  val += 3;  i = new Integer (val);  } public static void main (String args [ ] )  {  Integer  i = new Integer (0);  add3 (i);  system.out.printIn (i.intValue ( )  );  } What is the result?()A  Compilation will fail.B  The program prints “0”.C  The program prints “3”.D  Compilation will succeed but an exception will be thrown at line 3.

考题 多选题1. import java.util.*;  2.  3. Class FindStuff {  4. public static void  main(String [] args) {  5. // insert code here  6. c.put("x", 123);  7. }  8. } 分别插入到第5行,哪三行允许代码编译?()AMap c = new SortedMap();BHashMap c = new HashMap();CHashMap c = new Hashtable();DSortedMap c = new TreeMap();

考题 单选题class Beta {  public static void main(String [] args) {  Integer x = new Integer(6) * 7;  if (x != 42) {  System.out.print("42 ");  } else if (x 〈 new Integer(44-1)) {  System.out.println("less");  } else {  System.out.print("done"); } } }  结果是什么?()A lessB 42C doneD 编译失败

考题 单选题1. public class A {  2. void A() {  3. System.out.println(“Class A”);  4. }  5. public static void main(String[] args) {  6. new A();  7. }  8. }  What is the result?()A  Class AB  Compilation fails.C  An exception is thrown at line 2.D  An exception is thrown at line 6.E  The code executes with no output.