1.public classA{ 2.public String doit(intx,inty){ 3.return"a"; 4.} 5. 6.public String doit(int...vals){ 7.return"b"; 8.} 9.} And: 25.A a=new A(); 26.System.out.println(a.doit(4,5)); What is the result?()A、Line 26 prints "a" to System.out.B、Line 26 prints "b" to System.out.C、An exception is thrown at line 26 at runtime.D、Compilation of class A will fail due to an error in line 6.
1.public classA{ 2.public String doit(intx,inty){ 3.return"a"; 4.} 5. 6.public String doit(int...vals){ 7.return"b"; 8.} 9.} And: 25.A a=new A(); 26.System.out.println(a.doit(4,5)); What is the result?()
- A、Line 26 prints "a" to System.out.
- B、Line 26 prints "b" to System.out.
- C、An exception is thrown at line 26 at runtime.
- D、Compilation of class A will fail due to an error in line 6.
相关考题:
在C盘当前文件夹下有一个已建立好的顺序文件Alph.txt,文件内容为只含有字母的一个字符串(有双引号界定符)。单击窗体,打开Alph.txt文件,读取字符串并显示在文本框Text1中,然后调用StrSort过程将此字符串按ASCII码的顺序重新排列并显示在文本框Text2中,最后将重新排列的字符串存入AlpO.txt文件中(无双引号界定符)。请选择横线处合适的语句( )。Private Sub Form_Load()Dim StrIn As String,StrOut As StringsOpen"C:\Alph.txt"For Input As #1______CloseText1.Text=StrIn______Text2.Text=StrOutOpen"C:\AlpO.txt"For Output As#2______CloseEnd SubPrivate Function StrSort(s As String)As StringDim s Arr() As String *1,i As Integer,j As Integer,n As IntegerDim t As String *1n=Len(s)ReDim sArr(n)For i=1 To ns Arr(i)=Mid(s,i,1)Next iFor i=1 To n-1For j=i+1 To nIf sArr(i)>sArr(j) Thent=sArr(i):sArr(j):sArr(j):sArr(j)=tEnd IfNext j,iFor i=1 To nStrSort=StrSort s Arr(i)Next iEnd FunctionA.Input#1,StrIn StrIn Print#2,StrOutB.Input#1,StrIn StrSort(StrIn) Input#2,StrOutC.Input#2,StrIn StrSort(StrIn) Input#1,StrOutD.Print#1,StrIn StrSort(StrIn) Input#2,StrOut
(35)在C盘当前文件夹下有一个已经建立好的顺序文件Alph.txt,文件内容为只含有字母的一个字符去、串(有双引号界定符)。单击窗体,打开Alph.txt文件,读取字符串显示在文本框Text1中,最后将重新排列的字符串存入AipO.txt文件中(无双引号界定符)。请选择横线处合适的语句 Private Sub Fom_Load() Dim StrIn As String,StrOut As String Open"C/:Alph.txt"For Input As#1 ______ Close Text1.Text=StrIn ______ Text2.Text=StrOut Open"C/:AlpO.txt"For Output As#2 ______ Close End Sub Private Function StrSort(s As String)As String Dim sArr()As String*1,i As Integer,j As Integer,n As Integer Dim t As String*1 n=Lem(s) Redim sArr(n) For i=1 To n sArr(i)=Mid(s,i,1) Next i For i=1 To n-1 For j=i+1 To n If sArr(i)sArr(j)Then t=sArr(i):sArr(i)=sArr(j):sArr(j)=t End If Next j,i For i=1 To n StrSort=StrSortsArr(i) Next i End FunctionA.Input#1,StrIn StrIn Print#2,StrOut B.Input#1,StrIn StrOut(StrIn) Print#2,StrOutC.Input#2,StrIn StrOut(StrIn) Print#1,StrOutD.Input#1,StrIn StrOut(StrIn) Input#2,StrOut
请完成下列Java程序:输出某年的某月有多少天数,要求生成2个输入对话框,一个输入年份,一个输入月份,并且能检查输入的数字是否符合要求,如果符合要求,则根据输入的年份和月份计算出这一年的这一月有多少天。提示:闰年为年数能被4整除但是不能被100整除。注意:请勿改动main()主方法和其他已有语句内容,仅在下划线处填入适当的语句。程序运行结果如下:import javax.swing. JOptionPane;public class ex10_2 {public static void main(String[] args) (String strIn;int nYear,nMonth,nNumOfDays=0;strIn=JOptionPane.showInputDialog(,,year.);nYear=Integer.parseInt(strIn);if(nYear<0) {System.out.println("Invalidate number of year!")return;} strIn=JOptionPane.showInputDialog("month.);nMonth=Integer.parseInt(strIn);if(_____________) {System.out.println("Invalidate number of month!"return;}switch(nMonth){case 1:case 3:case 5:case 7:case 8:case 10:case 12:nNumOfDays=31;break;case 4:case 6:case 9:case 11:nNumOfDays=30;break;case 2:if(________________)nNumOfDays=29;elsenNumOfDays=28;break;}System.out.println("Number of days:"+ nNumOfDays);}}
Whatproducesacompilererror?() A.classA{publicA(intx){}}B.classA{}classBextendsA{B(){}}C.classA{A(){}}classB{publicB(){}}D.classZ{publicZ(int){}}classAextendsZ{}
InwhichtwocasesdoesthecompilersupplyadefaultconstructorforclassA?() A.classA{}B.classA{publicA(){}}C.classA{publicA(intx){}}D.classZ{}classAextendsZ{voidA(){}}
Click the Exhibit button. 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; public class ClassA { int x=20: static int y=6; public static void main(String args[]) { ClassB b=new ClassB; go(10); System.out.println("x="+b.x); } } class ClassB { int X; void go(int y) { ClassA a=new ClassA; x=a.Y ; } }A.x=10B.x=20C.x=6D.编译不通过
下面程序输出的结果为( )。 #include"iostream.h" classA {public: A(){cOUt"CLASSA"endl;} ~A(){}}; ClaSSB:publicA {public: B(){cout"CLASSB"endl;} ~B(){}}; voidmain() {A*P; P=newB: B*q: q=newB;}A.CLASSAB.CLASSA CLASSBCLASSB CLASSBC.CLASSAD.CLASSA CLASSBCLASSB CLASSACLASSB CLASSBCLASSB
有如下模板声明:templatetypenameT1,typenameT2classA;下列声明中,与上述声明不等价的是( )。A.templateclassTl,classT2classA;B.templateclassT1,typenameT2classAtC.templatetypenameT1,classT2classA;D.templatetypenameT1,T2classA;
下面程序输出的结果为( )。 includeiostream.hclassA{public: A(){cOUtiostream.hclassA{public:A(){cOUtCLASSAendl;}~A(){}};ClaSSB:publicA{public:B(){coutCLASSBendl;}~B(){}};voidmain(){A*P;P=newB:B*q:q=newB;}A.CLASSBB.CLASSA CLASSB CLASSBC.CLASSA CLASSB CLASSA CLASSBD.CLASSA CLASSB CLASSB CLASSB
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.
Given: class ClassA {} class ClassB extends ClassA {} class ClassC extends ClassA {} and: ClassA p0 = new ClassA(); ClassB p1 = new ClassB(); ClassC p2 = new ClassC(); ClassA p3 = new ClassB(); ClassA p4 = new ClassC(); Which three are valid?()A、p0 = p1;B、p1 = p2;C、p2 = p4;D、p2 = (ClassC)p1;E、p1 = (ClassB)p3;F、p2 = (ClassC)p4;
1.public class test ( 2.public static void main (String args[]) { 3.int i = 0xFFFFFFF1; 4.int j = ~i; 5. 6.} 7.) What is the decimal value of j at line 5?() A、 0B、 1C、 14D、 –15E、 An error at line 3 causes compilation to fail.F、 An error at line 4 causes compilation to fail.
1.public class Test { 2.public static void main (String args[]) { 3.class Foo { 4.public int i = 3; 5.} 6.Object o = (Object) new Foo(); 7.Foo foo = (Foo)o; 8.System.out.printIn(foo. i); 9. } 10.} What is the result?() A、 Compilation will fail.B、 Compilation will succeed and the program will print “3”C、 Compilation will succeed but the program will throw a ClassCastException at line 6.D、 Compilation will succeed but the program will throw a ClassCastException at line 7.
单选题1.public class test ( 2.public static void main (String args[]) { 3.int i = 0xFFFFFFF1; 4.int j = ~i; 5. 6.} 7.) What is the decimal value of j at line 5?()A 0B 1C 14D –15E An error at line 3 causes compilation to fail.F An error at line 4 causes compilation to fail.
单选题Click the Exhibit button. Given: ClassA a = new ClassA(); a.methodA(); What is the result?()A The code runs with no output.B Compilation fails.C An exception is thrown at runtime.D ClassC is displayed.
单选题1.public classA{ 2.public String doit(intx,inty){ 3.return"a"; 4.} 5. 6.public String doit(int...vals){ 7.return"b"; 8.} 9.} And: 25.A a=new A(); 26.System.out.println(a.doit(4,5)); What is the result?()ALine 26 prints a to System.out.BLine 26 prints b to System.out.CAn exception is thrown at line 26 at runtime.DCompilation of class A will fail due to an error in line 6.
单选题class ClassA { public int numberOfinstances; protected ClassA(int numberOfinstances) { this.numberOflnstances = numberOfinstances; } } public class ExtendedA extends ClassA { private ExtendedA(int numberOfinstances) { super(numberOflnstances); } public static void main(String[] args) { ExtendedA ext = new ExtendedA(420); System.out.print(ext.numberOflnstances); } } Which is true?()A 420 is the output.B An exception is thrown at runtime.C All constructors must be declared public.D Constructors CANNOT use the private modifier.E Constructors CANNOT use the protected modifier.
单选题类ClassA有一个名为M1的方法,在程序中有如下一段代码,假设该段代码是可以执行的,则声明M1方法时一定使用了()修饰符。 ClassA Aobj=new ClassA(); ClassA.M1();A publicB public staticC privateD virtual
单选题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
多选题Given: class ClassA {} class ClassB extends ClassA {} class ClassC extends ClassA {} and: ClassA p0 = new ClassA(); ClassB p1 = new ClassB(); ClassC p2 = new ClassC(); ClassA p3 = new ClassB(); ClassA p4 = new ClassC(); Which three are valid?()Ap0 = p1;Bp1 = p2;Cp2 = p4;Dp2 = (ClassC)p1;Ep1 = (ClassB)p3;Fp2 = (ClassC)p4;
多选题现有: class ClassA {} class ClassB extends ClassA {) class ClassC extends ClassA {) 以及: ClassA p0=new ClassA(); ClassB pl=new ClassB(); ClassC p2=new ClassC(); ClassA p3=new ClassB(); ClassA p4=new ClassC(); 下列哪些是正确的?()Ap0=pl;Bp1 =p2;Cp2=p4;Dp2 = (ClassC)pl;Ep1 = (ClassB)p3;Fp2 = (Classc)p4;
单选题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?()A1B2CCompilation fails.DThe code runs with no output.EAn exception is thrown at runtime.
单选题1.public class Test { 2.public static void main (String args[]) { 3.class Foo { 4.public int i = 3; 5.} 6.Object o = (Object) new Foo(); 7.Foo foo = (Foo)o; 8.System.out.printIn(foo. i); 9. } 10.} What is the result?()A Compilation will fail.B Compilation will succeed and the program will print “3”C Compilation will succeed but the program will throw a ClassCastException at line 6.D Compilation will succeed but the program will throw a ClassCastException at line 7.