在Java中,下列代码将输出()。1.publicclassintegerequals2.{3.publicstaticvoidmain(Stringargs[])4.{5.Integera=newInteger(3);6.Integerb=newInteger(3);7.System.out.println(a==b);8.}9.} A.编译器将显示第7行有错误B.程序编译并打印trueC.程序编译并打印falseD.程序编译但在第7行引起了一个运行期意外
在Java中,下列代码将输出()。1.publicclassintegerequals2.{3.publicstaticvoidmain(Stringargs[])4.{5.Integera=newInteger(3);6.Integerb=newInteger(3);7.System.out.println(a==b);8.}9.}
A.编译器将显示第7行有错误
B.程序编译并打印true
C.程序编译并打印false
D.程序编译但在第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); } }
1.importjava.util.*;2.publicclassExample{3.publicstaticvoidmain(String[]args){4.//insertcodehere5.set.add(newinteger(2));6.set.add(newinteger(l));7.System.out.println(set);8.}9.}Whichcode,insertedatline4,guaranteesthatthisprogramwilloutput[1,2]?()A.Setset=newTreeSet();B.Setset=newHashSet();C.Setset=newSortedSet();D.Listset=newSortedList();E.Setset=newLinkedHashSet();
publicclasstest{publicstaticvoidadd3(Integeri)intval=i.intValue();val+=3;i=newInteger(val);}publicstaticvoidmain(Stringargs[]){Integeri=newInteger(0);add3(i);system.out.printIn(i.intValue());}Whatistheresult?()A.Compilationwillfail.B.Theprogramprints“0”.C.Theprogramprints“3”.D.Compilationwillsucceedbutanexceptionwillbethrownatline3.
publicclassTest{publicstaticvoidadd3(Integeri){intval=i.intValue();val+=3;i=newInteger(val);}publicstaticvoidmain(Stringargs[]){Integeri=newInteger(0);add3(i);System.out.println(i.intValue());}}Whatistheresult?()A.0B.3C.Compilationfails.D.Anexceptionisthrownatruntime.
下列程序段不正确的是()。 A、string A=“firstJava”B、StringA= “firstJava”,A+=“Java”C、IntegerJ=new Integer(27),J-=7D、IntegerJ=new Integer(27),J- -
下面哪些代码在Java语言中是合法的? ( )A.string A="abcdefg"; A-="cde";B.string A="abcdefg"; A+="cde";C.Integer J=new Integer(27); J-=7;D.Integer J=new Integer(27); J--;
下面哪些代码在Java语言中是合法的? ( )A.stringA="abcdefg"; A-="Cde";B.stringA="abcdefg"; A+="cde";C.Integer J=new Integer(27); J-=7;D.Integer J=new Integer(27); J--;
阅读下面一段代码 Integer in1 = new Integer(10); Integer in2 = new Integer(10); Integer in3 = 10; Integer in4 = 10; System.out.print(in1 == in2); System.out.print(in1 == in3); System.out.print(in3 == in4); 下列选项中,程序的运行结果是()A.true true trueB.false false trueC.false false falseD.false true false
阅读下面一段代码,代码的输出结果是() Integer in1 = new Integer(10); Integer in2 = new Integer(10); Integer in3 = 10; Integer in4 = 10; System.out.print(in1 == in2); System.out.print(in1 == in3); System.out.print(in3 == in4);A.truetruetrueB.falsefalsetrueC.falsefalsefalseD.falsetruefalse