网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
floatf;Strings;现需要把float转化为String,正确的语句是()
- A、s=String.valueOf(f);
- B、f=Float.parseFloat(s);
- C、s=f;
- D、s=(String)f;
参考答案
更多 “floatf;Strings;现需要把float转化为String,正确的语句是()A、s=String.valueOf(f);B、f=Float.parseFloat(s);C、s=f;D、s=(String)f;” 相关考题
考题
下面哪段语法执行正确()
A.Strings=Gonewiththewind;Stringt=good;Stringk=s+t;B.Strings=Gonewiththewind;Stringt;t=s[3]+one;C.Strings=Gonewiththewind;Stringstandard=s.toUpperCase();D.Strings=homedirectory;Stringt=s-directory;
考题
在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
考题
分析下面的代码行 float f=3.2; int i=f; ,不正确地的答案是()
A、代码不能编译B、代码编译,i被设置为3C、第二行若改为inti=(byte)f则可编译D、第一行若改为floatf=3.2f则可编译
考题
importjava.util.*;publicclassLetterASort{publicstaticvoidmain(String[]args){ArrayListstrings=newArrayList();strings.add(?aAaA”);strings.add(”AaA”);strings.add(?aAa”);strings.add(”AAaa”);Collections.sort(strings);for(Strings:strings){System.out.print(s+);}}}Whatistheresult?()A.Compilationfails.B.aAaAaAaAAaaAaAC.AAaaAaAaAaaAaAD.AaAAAaaaAaAaAaE.aAaAaAaAaAAAaaF.Anexceptionisthrownatruntime.
考题
publicstaticvoidparse(Stringstr){try{floatf=Float.parseFloat(str);}catch(NumberFormatExceptionnfe){f=0;}finally{System.out.println(f);}}publicstaticvoidmain(String[]args){parse(”invalid”);}Whatistheresult?()A.0.0B.Compilationfails.C.AParseExceptionisthrownbytheparsemethodatruntime.D.ANumberFormatExceptionisthrownbytheparsemethodatruntime.
考题
classBaseClass{privatefloatx=1.0f;protectedvoidsetVar(floatf){x=f;}}classSubClassextendsBaseClass{privatefloatx=2.0f;//insertcodehere16.}Whichtwoarevalidexamplesofmethodoverriding?()
A.VoidsetVar(floatf){x=f;}B.PublicvoidsetVar(intf){x=f;}C.PublicvoidsetVar(floatf){x=f;}D.PublicdoublesetVar(floatf){x=f;}E.PublicfinalvoidsetVar(floatf){x=f;}F.ProtectedfloatsetVar(){x=3.0f;return3.0f;}
考题
Whichtwoarevaliddeclarationsofafloat?()
A.floatf=1F;B.floatf=1.0.;C.floatf=‘1’;D.floatf=“1”;E.floatf=1.0d;
考题
floatf[][][]=newfloat[3][][];floatf0=1.0f;float[][]farray=newfloat[1][1];Whatisvalid?()
A.f[0]=f0;B.f[0]=farray;C.f[0]=farray[0];D.f[0]=farray[0][0];
考题
Whichtwocauseacompilererror?()
A.float[]=newfloat(3);B.floatf2[]=newfloat[];C.float[]f1=newfloat[3];D.floatf3[]=newfloat[3];E.floatf5[]={1.0f,2.0f,2.0f};F.floatf4[]=newfloat[]{1.0f.2.0f.3.0f};
考题
下面的说法中正确的是( )。 Ⅰ:有float型数据定义float f1=100.00f;Float F1=new float(f1),要把float型转换为double型时用Double d1=F1.doubleValue()。 Ⅱ:有double型数据定义double d1=100.00;Double D1=new Double(d1),要把double型转换为int型时用 int il=D1.intValue()。 Ⅲ:当把int型转换为double型时,该转换是不能自动转换的,需要强制类型转换。 Ⅳ:以上说法都不对。A.Ⅱ、ⅢB.Ⅰ、ⅢC.Ⅰ、ⅡD.Ⅳ
考题
已知字符串A的值为"AbcDe",现要把它全部转化为大写字母并存放在A中,可使用语句( )。A.A=ToUpper$(A)B.A=ToLower$(A)C.A=Ucase$(A)D.A=Lcase$(A)
考题
import java.util.*; public class LetterASort { public static void main(String[] args) { ArrayList strings = new ArrayList(); strings.add(‟aAaA”); strings.add(”AaA”); strings.add(‟aAa”); strings.add(”AAaa”); Collections.sort(strings); for (String s: strings) { System.out.print(s + “ “); } } } What is the result?() A、 Compilation fails.B、 aAaA aAa AAaa AaAC、 AAaa AaA aAa aAaAD、 AaA AAaa aAaA aAaE、 aAa AaA aAaA AAaaF、 An exception is thrown at runtime.
考题
在java中,下列()语句不能通过编译。A、Strings="john"+"was"+"here";B、Strings="john"+3;C、floatf=5+5.5;D、inta=3+5;
考题
下面的方法重载,正确的是()。A、int fun(int a, float b) { } float fun(int a, float b) { }B、float fun(int a, float b) { } float fun(int x, float y) { }C、float fun(float a) { } float fun(float a, float b) { }D、float fun1(int a, float b) { } float fun2(int a, float b) { }
考题
如果需要把s="It,is,me"按照","分解,并赋给新的变量s1,下列语句正确的是()A、Strings1=newStringTokenizer(s);B、Strings1=newStringTokenizer(s,",");C、StringTokenizers1=newStringTokenizer("It,is,me");D、StringTokenizers1=newStringTokenizer(s,",");
考题
多选题1. import java.util.*; 2. public class Test { 3. public static void main(String[] args) { 4. List strings = new ArrayList(); 5. // insert code here 6. } 7. } Which four, inserted at line 5, will allow compilation to succeed?()AString s = strings.get(0);BIterator i1 = strings.iterator();CString[] array1 = strings.toArray();DIterator i2 = strings.iterator();EString[] array2 = strings.toArray(new String[1]);FIterator i3 = strings.iterator();
考题
单选题import java.util.*; public class LetterASort { public static void main(String[] args) { ArrayList strings = new ArrayList(); strings.add(‟aAaA”); strings.add(”AaA”); strings.add(‟aAa”); strings.add(”AAaa”); Collections.sort(strings); for (String s: strings) { System.out.print(s + “ “); } } } What is the result?()A
Compilation fails.B
aAaA aAa AAaa AaAC
AAaa AaA aAa aAaAD
AaA AAaa aAaA aAaE
aAa AaA aAaA AAaaF
An exception is thrown at runtime.
考题
单选题floatf;Strings;现需要把float转化为String,正确的语句是()A
s=String.valueOf(f);B
f=Float.parseFloat(s);C
s=f;D
s=(String)f;
热门标签
最新试卷