发布时间 : 星期五 文章java期末考试题更新完毕开始阅读
}
classs Dec{
public void decrement(int decMe){
decMe = decMe - 1;
}
}
2、以下程序的输出结果为 。(结果为: Boy)
public class Short{
public static void main(String args[ ]) {
StringBuffer s = new StringBuffer(“Boy”);
if((s.length( )<3)&& (s.append(“男孩”) . equals(“False”)))
;
“结果为: ”+s);
}
}
3、以下程序段的输出结果为 。(Message four)
int x=0,y=4, z=5;
if ( x>2){
if (y<5){
“Message one”);
}
else {
“Message two”);
}
}
else if(z>5){
“Message three”);
}
else {
“Message four”);
}
4、以下程序段的输出结果为 。(two.three.)
int j=2;
switch ( j ) {
case 2:
“two.”);
case 2+1 :
“three.”);
break;
default:
“value is “+j);
break;
}
5、以下程序段的输出结果为 。class Cruncher{
void crunch( int i ){
“int”);
}
(int)
void crunch(String s){
“String”);
}
public static void main(String args[ ]){
Cruncher crun=new Cruncher ( );
char ch=’p’;
crun.crunch(ch);
}
}
6、阅读以下程序,写出输出结果 。(99)
class Q6{
public static void main(String args[ ]){
Holder h=new Holder( );
h.held=100;
h.bump(h);
}