⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 java练习题(附答案)_临渊羡鱼,不如退而结网_新浪博客.htm

📁 基础类将帖子提前 放进我的网摘 推荐给好友 我要提问 帖子加分 生成帖子 置顶 推荐(加如何将数转换为数字
💻 HTM
📖 第 1 页 / 共 3 页
字号:
<DIV class=componentBottom></DIV></DIV>
<DIV class=component id=blog_904>
<DIV class=componentBar><SPAN class=title>推荐博文</SPAN></DIV>
<DIV class=componentContent>
<CENTER>内容读取中…</CENTER></DIV>
<DIV class=componentBottom></DIV></DIV>
<DIV class=component id=blog_12>
<DIV class=componentBar><SPAN class=title>谁看过这篇博文</SPAN></DIV>
<DIV class=componentContent>
<CENTER>内容读取中…</CENTER></DIV>
<DIV class=componentBottom></DIV></DIV></DIV></DIV>
<DIV class="gap floatLeft"></DIV>
<DIV class="column_2 floatLeft">
<DIV class="components730 SinaAd_hide" id=advertise_top></DIV>
<DIV class=components730>
<DIV class=component>
<DIV class=componentBar><SPAN class="floatRight articleFontSize" 
id=articleFontManage>字体大小:<A onclick="changeFontSize(2);return false;" 
href="http://blog.sina.com.cn/s/">大</A><B>中</B><A 
onclick="changeFontSize(0);return false;" 
href="http://blog.sina.com.cn/s/">小</A></SPAN> <SPAN class=title>正文</SPAN> <SPAN 
class=ARTICLE_HOT></SPAN></DIV>
<DIV class="componentContent article">
<DIV class=articleTitle>
<DIV style="DISPLAY: inline"><B id=t_48fb20f001007w8k>Java练习题(附答案)</B> <SPAN 
class=time>(2007-12-24 14:26:38)</SPAN> </DIV></DIV>
<DIV class=articleTag>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
    <TD>
      <SCRIPT>						var $tag='教育';						var $tag_code='c1e5bf8ad3bcff39635f8453a6bb36bd';                    </SCRIPT>
      标签:<A class=tag 
      href="http://uni.sina.com.cn/c.php?t=blog&amp;k=%BD%CC%D3%FD&amp;ts=bpost&amp;stype=tag" 
      target=_blank>教育</A><WBR>&nbsp; </TD>
    <TD vAlign=top align=right width=225>分类:<A 
      href="http://blog.sina.com.cn/s/articlelist_1224417520_2_1.html">VB/Java/C++/C#程序设计</A></TD></TR></TBODY></TABLE></DIV>
<DIV class=articleContent id=articleBody>
<DIV>
<P>11.在Java语言有多种实现的机制,下列哪种技术属于垃圾回收机制?<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
A、字节编译 B、内存跟踪 C、语法检查 D、堆栈上/下溢检查</P>
<P>12.编写和运行Java applet程序与编写和运行Java 
application程序不同的步骤是<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> A、编写源代码</P>
<P>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
B、编写HTML文件调用该小程序,以.html为扩展名存入相同文件夹<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> C、编译过程 
D、解释执行</P>
<P>13.下列哪个数代表八进制整数?<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> A、0Xa6 B、0144 C、1840 
D、-1E3</P>
<P>14.下列正确的句子是<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> A、float 3.14; B、byte i=225; 
C、k=33L; D、int p[][];</P>
<P>15.下列程序段的输出结果是<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> public class 
operatorsandExpressions{<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
void 
stringPlus(){<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
int 
x=3,y=4,z=5;<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
System.out.println(x+y+z);<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
}<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> }<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
A、xyz B、x+y+z C、12 D、以上答案均不正确</P>
<P>16.下列程序段的输出结果是<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> void 
doublearithmaticOperator<WBR>(){<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
System.out.print(9/2);<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
System.out.print(",");<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
System.out.println(5/2.0);<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
}<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> A、4.5,2.5 B、4,2 C、4.5,2 D、4,2.5</P>
<P>17.给出下面代码段:<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> public class 
Test1{<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> public static 
void main(String 
args[]){<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> int 
m;<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
switch(m)<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
{<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
case 0:System.out.println("case 
0");<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
case 1:System.out.println("case 
1");break;<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
case 
2:<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
default:System.out.println("default");<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
}<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
}<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> }<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
下列m 的哪个值将引起“default”的输出?<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> A、0 B、1 C、2 
D、以上答案都不正确</P>
<P>18.下列程序的输出结果为<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> int 
j=2;<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
switch(j){<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
case 
2:<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
System.out.println("Value is 
two.");<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
case 
2+1:<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
System.out.println("Value is 
three.");<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
break;<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
default:<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
System.out.println("Value is 
"+j);<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
break;}<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> A、Value is 
two.<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> B、Value is 
two.<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> Value 
is three.<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> C、Value is 
two.<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> Value 
is three.<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
Value is 2<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> D、编译错误</P>
<P>19.下列哪个类声明是正确的?<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> A、abstract final class 
Hl{…} B、abstract private move(){…}<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
C、protected private number; D、public abstract class Car{…}</P>
<P>20.对于构造方法,下列叙述不正确的是<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
A、构造方法是类的一种特殊方法,它的方法名必须与类名相同。<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
B、构造方法的返回类型只能是void型,且书写格式是在方法名前加void前缀。<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
C、构造方法的主要作用是完成对类的对象的初始化工作。<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
D、一般在创建新对象时,系统会自动调用构造方法。</P>
<P>21.不使用static修饰符限定的方法称为成员方法,下列哪一个说法是不正确的?<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
A、成员方法可以直接调用父类的成员方法</P>
<P>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
B、成员方法可以直接调用父类的类方法<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
C、成员方法不可以直接调用其他类的成员方法</P>
<P>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> D、成员方法可以直接调用本类的类方法</P>
<P>22.关于私有访问控制符private修饰的成员变量,以下说法正确的是<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
A、可以被三种类所引用:该类自身、与它在同一个包中的其他类、在其他包中的该类的子类<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
B、可以被种类访问和引用:该类本身、该类的所有子类<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> C、只能被该类自身所访问和修改 
D、只能被同一个包中的类访问</P>
<P>23.关于以下程序段的说法正确的是<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 1. public class 
Myar{<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 2. public static void main(String 
argv[]){<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 3. int[]i=new 
int[5];<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 4. 
System.out.println(i[5]);<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 5. 
}<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 6. }<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
A、第2行编译出错 B、第4行编译出错<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> C、编译时产生错误 
D、编译时没有产生错误,运行时发生异常</P>
<P>24.编译并且执行以下代码,会出现什么情况?<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> public class 
Q{<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> public static void 
main(String 
argv[]){<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
int anar[]=new 
int[]{1,2,3};<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
System.out.println(anar[1]);<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> &nbsp;<WBR> 
}<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> }<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
A、1 B、有错误,数组anar在初始化以前不能正常输出。<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> C、2 
D、有错误,数组的大小没有定义。</P>
<P>25.如要抛出异常,应用下列哪种子句?<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> A、catch B、throw 
C、try D、finally</P>
<P>26.对于catch 子句的排列,下列哪种是正确的?<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> A、父类在先,子类在后 
B、子类在先,父类在后<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> C、有继承关系的异常不能在同一个 try 
程序段内<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> D、先有子类,其他如何排列都无关</P>
<P>27.当输入一个字节流时,要<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> A、实现DataInput接口 
B、实现ObjectInput接口<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> C、Serializable接口 
D、继承Reader抽象类</P>
<P>28.字符输出流类都是____抽象类的子类。<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> A、FilterWriter 
B、FileWrite C、Writer D、OutputStreamWrite</P>
<P>29.一个Java application 运行后,在系统中是作为一个<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> A、线程 
B、进程 C、进程或线程 D、不可预知</P>
<P>30.关于以下程序段的执行结果,说法正确的是<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> public class 
Borley extends 
Thread{<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
public static void main(String 
argv[]){<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
Borley b = new 
Borley();<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
b.start();<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
}<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> &nbsp;<WBR>public 
void 
run(){<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
&nbsp;<WBR> System.out.println("Running");<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
&nbsp;<WBR> }<BR>&nbsp;<WBR>&nbsp;<WBR> }<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 
A、编译通过并执行,但无输出 B、编译通过并执行,输出:Running<BR>&nbsp;<WBR>&nbsp;<WBR>&nbsp;<WBR> 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -