JAVA基础知识习题.doc_第1页
JAVA基础知识习题.doc_第2页
JAVA基础知识习题.doc_第3页
JAVA基础知识习题.doc_第4页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

JAVA基础知识习题.一、 选择1、 下面哪些是java语言中的关键字? A sizeof B abstract C NULL D Native2、 下面语句哪个是正确的? A char=abc; B long l=oxfff; C float f=0.23; D double=0.7E-3;3、以下程序测试String 类的各种构造方法,试选出其运行效果。class STRpublic static void main(String args)String s1=new String();String s2=new String(String 2);char chars=a, ,s,t,r,i,n,g;String s3=new String(chars);String s4=new String(chars,2,6);byte bytes=0,1,2,3,4,5,6,7,8,9;StringBuffer sb=new StringBuffer(s3);String s5=new String(sb);System.out.println(The String No.1 is +s1);System.out.println(The String No.2 is +s2);System.out.println(The String No.3 is +s3);System.out.println(The String No.4 is +s4);System.out.println(The String No.5 is +s5); A The String No.1 isThe String No.2 is String 2The String No.3 is a stringThe String No.4 is stringThe String No.5 is a string B The String No.1 isThe String No.2 is String 2The String No.3 is a stringThe String No.4 is tringThe String No.5 is a string C The String No.1 isThe String No.2 is String 2The String No.3 is a stringThe String No.4 is strinThe String No.5 is a string D 以上都不对4、下面语句段的输出结果是什么?int i = 9;switch (i) default:System.out.println(default);case 0:System.out.println(zero);break;case 1:System.out.println(one);case 2:System.out.println(two); A default B default, zero C error default clause not defined D no output displayed二、多项选择1、 下面哪些语句能够正确地生成5个空字符串?A String a=new String5; for(int i=0;i5;a+=);B String a=,;C String a5;D String5a;E String a=new String5; for( int i=0;i5;ai+=null);2、 下面哪些选项将是下述程序的输出? public class Outerpublic static void main(String args)Outer: for(int i=0; i3; i+)inner:for(int j=0;j1) break;System.out.println(j+and+i);A 0 and 0 B 0 and 1 C 0 and 2 D 0 and 3 E 2 and 2 F 2 and 1 G 2 and 03、 下面哪个语句正确地声明一个整型的二维数组?A int a = new int; B int a1010 = new int;C int a = new int1010; D int a = new int1010;E int a = new int1010;三、 编程题编写一个程序,用选择法对数组a=20,10,50,40,30,70,60,80,90,100进行从大到小的排序。以下是答案:一、 选择题答案 选择第1题B选择第2题D选择第3题A选择第4题B二、多项选择题答案多项选择第1题AB多项选择第2题ABC多项选择第3题CDE三、 编程题答案编程题public class ArraySortpublic static void main(String args)int array=20,10,50,40,30,70,60,80,90,100;int i,j,k,t;int l=array.length;for(i=0;iL-1;I+)k=i;for(j=i+1;jL;J+)if(arra

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论