String s
Integer i
boolean b
int i
第1题:
下列程序段运行的结果为 public class Test{ static void print(String s,int i){ System.out.println("String:"+s+",int:"+i); } static void print(int i,String s){ System.out.println("int:"+i+",String:"+s); } public static void main(String[]args){ print(99,"Int first"); } }
A.String:String first,int:11
B.int:11,String:Int first
C.String:String first,int99
D.int:99,String:Int first
第2题:
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.three
B.other
C.Anexceptionisthrownatruntime.
D.Compilationfailsbecauseofanerroronline12.
E.Compilationfailsbecauseofanerroronline13.
F.Compilationfailsbecauseofanerroronline15.
第3题:
为了从HTML文件中获取参数,在Applet程序中应该编写的代码是( )。
A.在start()方法中加入语句String s=getParameter("buttonLabel");
B.在int()方法中加入语句String s=Parameter("buttonLabel");
C.在int()方法中加入语句String s=getParameter("BUTTONLABEL");
D.在start()方法中加入语句String s=getParameter("BUTIONLABEL");
第4题:
已知前序后序求中序的一种
function ok(s1,s2:string):boolean;
var i,l:integer; p:boolean;
begin
ok:=true;
l:=length(s1);
for i:=1 to l do begin
p:=false;
for j:=1 to l do
if s1[i]=s2[j] then p:=true;
if not p then begin ok:=false;exit;end;
end;
end;
procedure solve(pre,post:string);
var i:integer;
begin
if (pre='''') or (post='''') then exit;
i:=0;
repeat
inc(i);
until ok(copy(pre,2,i),copy(post,1,i));
solve(copy(pre,2,i),copy(post,1,i));
midstr:=midstr+pre[1];
solve(copy(pre,i+2,length(pre)-i-1),copy(post,i+1,length(post)-i-1));
end;
第5题:
在switch(expression)语句中,expression的数据类型不能是( )。
A.double
B.char
C.byte
D.short
第6题:
执行下列程序段之后,变量b的值为______。 public class Test9 { public static void main(String[] args) { int i=12; int j=24; boolean b1=true; boolean b=(j%i== 0)&&(!b1) ||(j/i!=2); System.out.println(b); } }
A.true
B.假
C.1
D.0
第7题:
A.char c="/n";
B.int i=12;
C.float f=2.8;
D.boolean b=null;
第8题:
在switch(expression)语句中,expression的数据类型不能是()。
第9题:
在程序中将变量Inta、Bl、St、D分别定义为Integer类型、Boolean类型、String类型和Date类型,下列赋值语句中,正确的是()
第10题:
session.setAttribute(i,”I”)
session.setParameter(“I”,i)
session.setAttribute(new Integer(i),”I”)
session.setAttribute(“I”,new Integer(i))
第11题:
double
char
byte
short
第12题:
Bl=#True#
D=#10/05/01#
Inta=333+22
St=5+abc
第13题:
下列程序中,实现将封装数据类型Integer和基本数据类型int之间的转换,以及Integer,int类型和String类型之间的转换。请将程序补充完整。
程序运行结果如下:
123
456
456
public 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));
}
}
第14题:
下列程序段运行的结果为 public class Test{ static void print(String s,int i){ System.out.println("String:"+s+",int:"+i); } static void print(int i, String s){ System.out.println("int:"+i+",String:"+s); } public static void main(String [] args){ print(99,"Int first"); } }
A.String:Stringfirst,int:11
B.int:11,String:Int first
C.String:String first,int:99
D.int:99,String:int first
第15题:
阅读以下说明和Java 码,将应填入(n)处的字名写在的对应栏内。
[说明] 编写一个学生类Student,要求:
(1) 学生类Student 属性有:
id: long 型,代表学号
name: String类对象,代表姓名
age: int 型,代表年龄
sex: boolen 型,代表性别(其中:true 表示男,false 表示女)
phone: String 类对象,代表联系电话
(2) 学生类Student 的方法有:
Student (long i,String n,int a,boolean s,String p)
:有参构造函数,形参表中的参数分别初始化学号、姓名、
年龄、性别和联系电话。
int getAge ():获取年龄作为方法的返回值。
boolean getSex ():获取性别作为方法的返回值。
String getPhone ():获取联系电话作为方法的返回值。
public String to String ():以姓名:性别:学号:联系电话的形式作为方法的返
import java. applet. Applet;
import java. awt.* ;
public class Student extends Applet {
long id;
String name, phone;
int age;
boolean sex;
Student(long i, String n, int a, boolean s, String p)
{
id=i;
name = n;
age = a;
sex= s;
phone = p;
{
public void paint( Graphics g)
{
Student x= new Student (5000," xiaoliu" , 89, true, " 8989898" );
(1);
(2)
g. drawstring( x. getPhone( ), 140,140);
}
int getAge( )
{ return age; }
boolean getsex ( )
{ return sex; }
String getPhone( )
{ return phone; }
String ToString( )
{
(3)
}
}
第16题:
用整数10创建一个Integer类的对象,下列各语句中能完成此功能的是( )。
A.Integer i=new Integer(10);
B.Integer i=10;
C.int i=10;
D.Integer i=Integer(10);
第17题:
3下列程序段运行的结果为( )。 public class Test{ static void print(String s,int i){ System.out.pdntlnC String: "+s+",int:"+i); } static void print(iht i,String s){ System.out.prinflnCint:"+i+",gtring:"+s); } public static void main(String[] args){ print(99,"Int first"); } }
A.String:String first,int: 11
B.int: 11,String:Int first
C.String:String first,int:99
D. int:99,Stfing:Int first
第18题:
A. 3
B. 4
C. 5
D. 6
E. 语句if(i= 2、编译出错
第19题:
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? ()
第20题:
下面哪些语句能够正确地生成5个空字符串?()
第21题:
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?()
第22题:
three
other
Anexceptionisthrownatruntime.
Compilationfailsbecauseofanerroronline12.
Compilationfailsbecauseofanerroronline13.
Compilationfailsbecauseofanerroronline15.
第23题:
0
3
Compilation fails.
An exception is thrown at runtime.