java单选题
- 格式:doc
- 大小:262.00 KB
- 文档页数:64
单选题1.下面选项中,哪一个不是Java中的关键字A.sizeofB.constC.publicD.goto正确答案:A2.下列关于JDK的说法中,错误的是?A.JDK是Java开发工具包的简称B.JDK包括Java编译器、Java文档生成工具、Java打包工具等C.安装JDK后,还需要单独安装JRED.JDK是整个Java的核心正确答案:C3.下列关于while语句的描述中,正确的是A.while语句循环体中可以没有语句B.while语句的循环条件可以是整型变量C.while语句的循环体必须使用大括号D.while语句的循环体至少被执行一次正确答案:A4.在类的继承关系中,需要遵循以下哪个继承原则?A.多重B.单一C.双重D.不能继承正确答案:B5.请阅读下面的程序代码Class Person{void say(){System.out.println(“hello”);}}class Example{public static void main(String[] args){Person p2 = new Person();Person p1 = new Person();p2.say();p1.say();p2=null;p2.say();}}下列关于程序运行结果的描述中,正确的是()A.输出1个helloB.输出2个hello后会抛出异常C.输出3个hello后会抛出异常D.不会输出hello,直接抛出异常正确答案:B6.请阅读下面的程序片段boolean b=true;if(b=false) {System.out.println("a");} else if(b) {System.out.println(b);} else if(!b) {System.out.println("c");} else {System.out.println("d");}程序的执行结果是()A.aB.bC.cD.d正确答案:C7.下列关于case关键字的说法中,错误的是A.case关键字后面必须是常量B.case关键字后面的break必须存在C.case关键字后面的break可以没有D.case关键字后面的值必须不一样正确答案:B8.以下抽象类的定义中,错误的是?()A.abstract class Demo1{}B.abstract class Demo2{ public abstract String fun(String a); }C.abstract class Demo3{ public String fun(){ return "CZBK"; } }D.abstract class Demo4{ public static final String CZBK = "传智播客"; abstract void fun(){} } 正确答案:D9.已知类的继承关系如下:class Employee;class Manager extends Employeer;class Director extends Employee;则以下语句能通过编译的有哪些?A.Employee e=new Manager();B.Director d=new Manager();C.Director d=new Employee();D.Manager m=new Director();正确答案:A10.下列命令中,可以将文档注释提取出来生成帮助文档的是()A.javacB.javaC.javadocD.jar正确答案:C11.下列转义字符中,不合法的是()A.'\n'B.'\x'C.'\r'D.'\t'正确答案:B12.阅读下段代码,class Dog{public String name;Dog(String name){ =name;}}public class Demo1{public static void main(String[] args){Dog dog1 = new Dog("xiaohuang");Dog dog2 = new Dog("xiaohuang");String s1 = dog1.toString();String s2 = dog2.toString();String s3 = "xiaohuang";String s4 = "xiaohuang";}}返回值为true的是?()A.dog1.equals(dog2)B.s1.equals(s2)C.s3.equals(s4)D.dog1==dog2正确答案:C13.以下关于继承的描述,说法正确的是()A.子类继承父类的所有属性和方法B.子类可以继承父类的私有的属性和方法C.子类可以继承父类的公有的属性和方法D.创建子类对象时,父类的所有构造方法都会被执行正确答案:C14.函数重写与函数重载的相同之处是?()A.权限修饰符B.函数名C.返回值类型D.形参列表正确答案:B15.下列关于this关键字的说法中,错误的是()A、this可以解决成员变量与局部变量重名问题B、this出现在成员方法中,代表的是调用这个方法的对象C、this可以出现在任何方法中D、this相当于一个引用,可以通过它调用成员方法与属性A.this可以解决成员变量与局部变量重名问题B.this出现在成员方法中,代表的是调用这个方法的对象C.this可以出现在任何方法中D.this相当于一个引用,可以通过它调用成员方法与属性正确答案:C16.下列关于自定义异常的说法中,错误的是()A.自定义异常要继承Exception类B.自定义异常继承Exception类后,具有可抛性C.自定义异常可以在构造方法中用super关键字传递异常信息给父类D.自定义异常必须继承Error类正确答案:D17.请阅读下面的代码String s1=new String(“abc”);String s2=s1.intern();String s3=”abc”;System.out.println(s1==s2);System.out.println(s2==s3);System.out.println(s1==s3);下列选项中,程序的输出结果为()A.false true falseB.false false falseC.false true trueD.false false true正确答案:A18.请阅读下面的代码class A{int x;static int y;void fac(String s){System.out.println(“字符串:”+s);}}下列选项中描述正确的是()A.x , y和s 都是成员变量B.x 是实例变量,y是类变量,s是局部变量C.x和y是实例变量,s是参数D.x ,y和s都是实例变量正确答案:B19.阅读下列的代码public class Test {public static void main(String[] args) {__________________________________________________}}class Outer {static class Inner {public void method () {System.out.println("method");}}}下列选项中,填写在空白处可以使程序正常运行的是()A.Outer o = new Outer(); o.method();B.Inner I = new Inner(); i.method();C.Outer.Inner oi = new Outer.Inner(); oi.method();D.以上答案都不对正确答案:C20.下列关于Java特点的描述中,错误的是?A.Java语言不支持指针B.Java具有自动垃圾回收的机制C.Java只能运行在Window和Linux平台D.Java允许多个线程同时执行正确答案:C21.请阅读下面的代码片段public static int add(int a,int b) {return a + b;}下列选项中,可以在main()方法中成功调用add()方法的是A.int num = add(1.0,2.0);B.int num = add('a','b');C.int num = add(true,flase);D.int num = add("1","2");正确答案:B22.下了关于接口继承的说法中,正确的是?()A.接口继承自Object类B.一个接口只能继承一个接口C.一个接口可以继承多个接口D.接口不能被继承正确答案:C23.下列关于接口的描述,错误的是?()A.接口不是Object类的子类B.一个接口只能继承一个接口C.一个接口可以继承多个接口D.接口不能被实例化正确答案:B24.下面选项中,哪个关键字可以修饰局部变量?()A.abstractB.finalC.staticD.private正确答案:B25.阅读下列的程序public class Example {public static void main(String[] args) {new Father () {public void show() {System.out.println("helloworld");}}.show();}}class Father {public void show() {System.out.println("hellofather");}}A.hellofatherB.helloworldC.编译报错D.编译通过,运行报错正确答案:B26.下列关于注释的使用,错误的是?()A. int c = 10; //定义变量cB./* int c = 5; int x =6; */C./** 这是类的入口方法*/D./* /*int c = 10;*/ int x=5; */正确答案:D27.关于方法的递归,以下说法正确的是A.方法递归就是指在一个方法的内部调用自身的过程B.方法递归其实就是调用其它方法C.方法递归是指方法的返回值不同D.以上说法都不对正确答案:A28.请阅读下面的程序public class Example {public static void main(String[] args) {int x = 1;do {x++;} while (x <= 4);System.out.println("x = " + x);}}程序的运行结果是A.3B.4C.5D.6正确答案:C29.若二维数组int arr[][]={{1,2,3},{4,5,6},{7,8}};,则arr[1][2]的值是()A.2B.5C.6D.0正确答案:C30.下列选项中,按照箭头方向,需要进行强制类型转换的是A.int ←shortB.int ←byteC.int ←charD.int ←float正确答案:D31.下列关于构造方法的描述中,错误的是()A.构造方法的方法名必须和类名一致B.构造方法不能写返回值类型C.构造方法可以重载D.构造方法的访问权限必须和类的访问权限一致正确答案:D32.while语句的循环体中不能包含的语句是A.while语句B.方法定义语句C.if语句D.switch语句正确答案:B33.分析下面程序,哪一行代码能正确赋值?()class Demo {public void method() {final int num1 = 10;static int num2 = 20;abstract int num3 = 30;private int num4 = 40;}}A.final int num1 = 10;B.static int num2 = 20;C.abstract int num3 = 30;D.private int num4 = 40;正确答案:A34.以下抽象类的定义中,错误的是?()A.abstract class Demo1{}B.abstract class Demo2{ public abstract String fun(String a); }C.abstract class Demo3{ public String fun(){ return "CZBK"; } }D.abstract class Demo4{ public static final String CZBK = "传智播客"; abstract void fun(){} }正确答案:D35.已知类的继承关系如下:class Aclass B extends Aclass C extends A则以下语句中能够通过编译的是?()A.A a=new B();B.C c=new B();C.C c=new A();D.B b=new C();正确答案:A36.Person p = new Person(“张三”,23);这条语句会调用下列哪个构造方法给属性进行初始化()A.public Person(){}B.public Person(String name,int age) { = name; this.age = age; }C. public Person(int age,String name) { this.age = age; = name; }D.public Person(String name) { = name; }正确答案:B37.阅读下面的程序public class Test {public static void main(String[] args) {for(int x = 0 ; x <=3 ; x++){continue;System.out.print(x%2);}}}运行结果正确的是A.跳出循环,无输出B.0121C.01D.0123正确答案:A38.下面关于整数类型的描述中,错误的是()A.byte是java中的整数类型,它的取值范围是-127到128。
一、单选题:(每题1分)下列各题A)、B)、C)、D)四个选项中,只有一个选项是正确的,请将正确选项的标记写在题干后的括号内。
1.下列语句序列执行后,k 的值是( B )。
int m=3, n=6, k=0;while( (m++) < ( -- n) ) ++k;A) 0 B) 1 C) 2 D) 32.设 i、j 为int型变量名,a 为int型数组名,以下选项中,正确的赋值语句是( B )。
A) i = i + 2 B) a[0] = 7;C) i++ - --j; D) a(0) = 66;3.Java语言的类间的继承关系是( B )。
A) 多重的 B) 单重的 C) 线程的 D) 不能继承4.设有定义 int i = 6 ;,则执行以下语句后,i 的值为( C )。
i += i - 1;A) 10 B) 121 C) 11 D) 1005.下列选项中,用于在定义子类时声明父类名的关键字是( C )。
A)interface B) package C) extends D) class6.若已定义 byte[ ] x= {11,22,33,-66} ;其中0≤k≤3,则对x数组元素错误的引用是( C )。
A) x[5-3] B) x[k] C) x[k+5] D) x[0]7.下列语句序列执行后,ch1 的值是( B )。
char ch1='A',ch2='W';if(ch1 + 2 < ch2 ) ++ch1;A) 'A' B) 'B' C) 'C' D) B8.下列语句序列执行后,i 的值是( D )。
int i=8, j=16;if( i-1 > j ) i--; else j--;A) 15 B) 16 C) 7 D) 89.下列语句序列执行后,k 的值是( C )。
int i=10, j=18, k=30;switch( j - i ){ case 8 : k++;case 9 : k+=2;case 10: k+=3;default : k/=j;}A) 31 B) 32 C) 2 D) 3310.下面语句执行后,i 的值是( B )。
java试题库及答案Java试题库及答案一、单选题1. Java语言的特点是什么?A. 面向过程B. 面向对象C. 编译型语言D. 解释型语言答案:B2. 在Java中,用哪个关键字可以定义一个类?A. publicB. classC. voidD. int答案:B3. 下列哪个是Java的合法标识符?A. 2classB. class#2C. _class2D. class:2答案:C4. Java中的main()方法必须定义为什么类型的参数?A. intB. StringC. voidD. None答案:D5. 在Java中,哪个关键字用于实现异常处理?A. tryB. catchC. throwD. All of the above答案:D二、多选题6. 下列哪些是Java的基本数据类型?A. intB. StringC. floatD. boolean答案:A, C, D7. 在Java中,哪些是合法的数组初始化方式?A. int[] arr = new int[10];B. int arr[] = {1, 2, 3};C. int arr = {1, 2, 3};D. int arr = new int[3]{1, 2, 3};答案:A, B8. 下列哪些是Java的控制流语句?A. if-elseB. switch-caseC. forD. try-catch答案:A, B, C三、简答题9. 简述Java的垃圾回收机制。
答案:Java的垃圾回收机制是一种自动内存管理功能,它周期性地执行,回收不再使用的对象所占用的内存空间。
垃圾回收器会跟踪每个对象的引用,当对象的引用计数为0时,即没有任何引用指向该对象,垃圾回收器就会在下一次执行时回收该对象占用的内存。
10. 什么是Java的接口?它有什么作用?答案:Java中的接口是一种完全抽象的类,它不包含任何实现代码,只包含常量和抽象方法的声明。
11111111111111单选题第一套1-1-1-1下面的main()方法的定义哪些是正确的?()(A)public static void main(String args){}(B)public static void main(String[]){}(C)public static void main(String[] args){}(D)public static void MAIN(String[] xyz){}答案:C1-1-2-1用于定义简单数据类型的一组关键字是()(A)Student,float,main,public(B)byte,boolean,int,float(C)long,extends,float,double(D)class,float,short,import答案:B1-1-3-1以下变量定义中正确的是()(A)int I=123a (B)float f=7.8f(C)char c=’abc’ (D)String str=’d’答案:B1-1-4-1 for(;;)是( )(A)循环结构 (B)分支结构 (C)顺序结构答案:A1-1-5-1设类B和类C都不是抽象类,且类B是类C的父类。
下列声明对象x1的语句中不正确的是( )(A) B x1=new B() (B) B x1=new C()(C) C x1=new C() (D) C x1=new B()答案:D1-1-6-1设有对象x具有属性a则访问该属性的方法为()(A) a.x (B) a.x() (C) x.a (D) x.a()答案:C1-1-7-2定义变量如下:int i=18;long L=5;float f=9.8f;double d=1.2;String s=”123”;以下赋值语句不正确的是()(A)L=f+i (B)f=L+i(C)s=s+i (D)s=s+i+f+d答案:A1-1-8-2下面表达式的值的类型为()(int)(8/9.2*5)(A)short (B)int (C)double (D)float答案:B1-1-9-2 设数组Array由以下语句定义int Array=new int[10],则数组最后一个元素的正确引用方法为( )(A)Array[10] (B)Array[9] (C)array[10] (D)array[9]答案:B1-1-10-2 定义类A如下:()class A{int a,b,c;public void B(int x,int y,int z){ a=x;b=y;c=z;}}下面对方法B()的重载哪些是正确的()?(A)public void A(int x1,int y1,int z1){a=x;b=y;c=z;}(B)public void B(int x1,int y1,int z1){a=x;b=y;c=z;}(C)public void B(int x,int y){a=x;b=y;c=0;}(D)public B(int x,int y,int z){a=x;b=y;c=z;}答案:C1-1-11-2定义一个类Point,类中有两个double型变量x和y,对于其构造函数的声明不正确的是()(A) public Point(Point p ){…} (B) public Point(int x ){…}(C) public Point(int x,int y ){…} (D) Point Point(int x ){…}答案:D1-1-12-2 以public修饰的类如:public class Car{…} 则Car( )(A)可被其它程序包中的类使用(B)仅能被本程序包中的类使用(C)不能被任意其它类使用 (D)不能被其它类继承答案:A1-1-13-2下列说法哪个正确?(A)不需要定义类,就能创建对象(B)对象中必须有属性和方法(C)属性可以是简单变量,也可以是一个对象(D)属性必须是简单变量答案:C1-1-14-3覆盖与重载的关系是()(A)覆盖只有发生在父类与子类之间,而重载可以发生在同一个类中(B)覆盖方法可以不同名,而重载方法必须同名(C)final修饰的方法可以被覆盖,但不能被重载(D)覆盖与重载是同一回事答案:A1-1-15-3执行下列程序段后,b,x,y的值正确的是()int x=6,y=8;boolean b;b=x<y||++x= =--y;(A)true,6,8 (B)false,7,7(C)true,7,7 (D)false ,6,8答案:A单选题第二套1-2-1-1下面说法正确的是()(A)Java程序的源文件名称与主类(公共类)的名称相同,后缀可以是java或txt(B)JDK的编译命令是java(C)一个java源程序编译后可能产生几个字节码文件(D)在命令行运行编译好的字节码文件,只需在命令行直接键入程序名即可运行该程序答案:C1-2-2-1以下变量定义语句正确的是()(A)char c=”中” (B)double d=89L(C)byte b=512 (D)double a=8.6f答案:B1-2-3-1有关Java语言的说法中,哪种是错误的()(A) java是高级语言 (B) java是编译型语言(C)java是结构化设计语言(D) java是移植性强的语言答案:C1-2-4-1 JDK是( )(A)一种全新的程序语言(B)一种程序开发辅助工具(C)一种由Java写成的,并支持Java Applet的浏览器(D)一种游戏软件答案:B1-2-5-1关于构造函数的说法哪个正确?()(A)一个类只能有一个构造函数(B)一个类可以有多个不同名的构造函数(C)构造函数与类同名(D)构造函数必须自己定义,不能使用父类的构造函数答案:C1-2-6-1下列关于finally的说法正确的是?()(A)无论程序是否找到合适的例外控制器,都会去执行finally语句(B)finally语句应该放在所有例外控制器的最前面(C)如果程序在前面的例外控制器中匹配到了合适例外,就不再执行finally语句(D)如果程序在前面的例外控制器中匹配到了多个合适的例外,就不再执行finally语句答案:A1-2-7-2以下语句输出的结果是()String str=”123”;int x=4,y=5;str=str+x+y;System.out.println(str);(A)int 1239 (B)12345(C)回产生编译错误 (D)123+4+5答案:B1-2-8-2定义类头时可以使用的访问控制修饰符是()(A)public (B)abstract (C)final (D)private答案:A1-2-9-2下面的程序段输出的结果是()int i=1,b,c;int[] a=new int[3];b=a[i];c=b+i;System.out.println(c );(A)0 (B)2 (C)4 (D)1答案:D1-2-10-2 构造函数何时被调用?()(A)创建对象时(B)类定义时(C)使用对象的方法时(D)使用对象的属性时答案:A1-2-11-2抽象类与接口的区别在于:()(A)抽象类可以实现多重继承,而接口不行(B)抽象类不可以继承,而接口可以(C)抽象类中可以有非抽象的方法,而接口中只能有抽象方法(D)接口只是抽象类的另一种叫法答案:C1-2-12-2关于继承的说法正确的是:()(A)子类将继承父类所有的属性和方法。
Java试题(附答案)⼀、单选题(每道⼩题只有⼀个正确的选项)1、Java程序中要⽤变量来存储学⽣性别信息,从节约内存空间的⾓度最好选择哪种数据类型( D )A)int B)short C)byte D)boolean2、Java语⾔中基本的数据类型不包括( C ):A)整型B)浮点型C)数组D)逻辑型3、Java程序中⽤来定义常量必须⽤到的关键字是(A)A)final B)class C)void D)static4、下列属于Java语⾔中字符常量的是( B )A)”m”B)‘!’C)a D)$5、⼀个简单的Java程序可能没有⽤到的关键字是(C )A)void B)public C)int D)static6、下列关于Java程序中数组的使⽤说法正确的是(A)A)数组必须在使⽤前定义B)同⼀个数组中的元素类型必须不同C)数组是⼀种特殊的变量不需在使⽤前声明D)数组的元素不可以是数组7、程序设计语⾔的发展主要经历了三个阶段,其中不包括(A)A)数学语⾔B)机器语⾔C)汇编语⾔D)⾼级语⾔8、关于程序设计语⾔下列说法错误的是( C )A)Java、C++、VB等都是当前⼴泛使⽤的⾼级程序设计语⾔。
B)⼀项任务可以使⽤多种语⾔来实现,使⽤前需要综合考虑选择合适的语⾔。
C)因特⽹的应⽤开发必须使⽤Java语⾔来实现。
D)Java是⼀种完全⾯向对象的⾼级语⾔,在因特⽹的应⽤开发中⼴泛应⽤。
9、经过编译后的Java程序的扩展名是( B )A).java B).class C).exe D).bat10、关于Java源程序的说法错误的是( C )A)⽂件名必须和主类名⼀致B)使⽤“javac”对java程序进⾏编译C)java程序的编译运⾏须借助辅助软件D)java源程序的扩展名为.java11、若已定义x和y是double型变量,则表达式x=1,y=x+3/2执⾏后y的值为( D )A)1 B)2 C)3 D)2.512、Java语⾔中整型常量有三种形式即⼋进制整数、⼗进制整数和⼗六进制整数。
java选择试题及答案一、单项选择题(每题2分,共10分)1. 在Java中,下列哪个关键字用于定义一个接口?A. classB. interfaceC. abstractD. enum答案:B2. 下列哪个选项是Java语言中合法的变量名?A. 2numberB. _nameC. name$D. name答案:D3. 在Java中,下列哪种数据类型不是基本数据类型?A. intB. floatC. StringD. double答案:C4. 下列哪个关键字用于抛出异常?A. catchB. throwC. tryD. finally答案:B5. 在Java中,下列哪个方法用于将字符串转换为浮点数?A. parseInt()B. parseFloat()C. toInt()D. toFloat()答案:B二、多项选择题(每题3分,共15分)1. 下列哪些选项是Java中的访问修饰符?A. publicB. privateC. protectedD. static答案:A B C2. 在Java中,下列哪些关键字用于控制流程?A. ifB. elseC. switchD. break答案:A B C D3. 下列哪些选项是Java集合框架中接口?A. ListB. MapC. SetD. ArrayList答案:A B C4. 在Java中,下列哪些关键字用于定义方法?A. voidB. staticC. synchronizedD. final答案:A B C D5. 下列哪些选项是Java中的错误处理机制?A. tryB. catchC. finallyD. throw答案:A B C D三、判断题(每题1分,共5分)1. Java中的main方法必须声明为public static void。
答案:正确2. Java中的数组长度是可变的。
答案:错误3. Java中的类可以被继承,但接口不能被继承。
Java练习题一、单选题1. Java程序的执行过程中用到一套JDK工具,其中java.exe是指(B )A. Java文档生成器B. Java解释器C. Java编译器D. Java类分解器2. 编译Java程序的命令文件名是(B )A. java.exeB. javac.exeC. javacD. appletviewer.exe3. 编译Java程序file.java后生成的程序是(C )A. file.htmlB. File.classC. file.classD. file.jar4. Java语言与其他主要语言相比较,独有的特点是(C )A. 面向对象B. 多线程C. 平台无关性D. 可扩展性5. 声明Java独立应用程序main()方法时,正确表达是(A )A. public static void main(String[] args){…}B. private static void main(String args[]){…}C. public void main(String args[]){…}D. public static void main(){…}6. 下列有关Java语言的叙述中,正确的是(B )。
A. Java是不区分大小写的B. 源文件名与public类型的类名必须相同C. 源文件的扩展名为.jarD. 源文件中public类的数目不限7. Java用来定义一个新类时,所使用的关键字为(A )。
A. classB. publicC. structD. class 或struct 8.一个可以独立运行的Java应用程序(D )。
A. 可以有一个或多个main方法B. 最多只能有两个main方法C. 可以有一个或零个main方法D. 只能有一个main方法9. 下面哪个是Java语言中正确的标识符(B )A. 3DB. $thisC. extendsD. implements10. 下面哪个不是Java的保留字或关键字?(B)A. defaultB. NULLC. throwsD. long11. 对if(…)句型括号中的表达式,下列Java类型中哪一个是合法的?(C )A. byteB. shortC. booleanD. Object reference12. Java中整型包括( D )。
java考试题及答案一、单选题1. 在Java中,以下哪个关键字用于定义一个类?a) classb) newc) publicd) void答案:a) class2. 下列选项中,哪个是Java的基本数据类型?a) Stringb) Integerc) Booleand) Object答案:c) Boolean3. 下面哪个关键字用于创建一个新的实例对象?a) staticb) finalc) instance答案:d) new4. Java中的继承是指什么?a) 一个类实现另一个类的属性和方法b) 一个类派生出另一个类,新类拥有原来类的属性和方法c) 一个类使用另一个类的属性和方法d) 一个类包含另一个类的属性和方法答案:b) 一个类派生出另一个类,新类拥有原来类的属性和方法5. 在Java中,以下哪个关键字用于声明一个变量不可修改?a) constantb) finalc) staticd) abstract答案:b) final二、多选题1. 以下哪些操作符可以用于控制流程?a) ifb) ford) switch答案:a) ifb) forc) whiled) switch2. Java中的异常处理机制包括以下哪些部分?a) tryb) catchc) throwd) finally答案:a) tryb) catchd) finally三、简答题1. 请简要解释Java中的多态性是什么意思。
答案:Java中的多态性是指同一个接口,能够有多个不同的实现类。
通过多态性,可以实现方法的动态绑定,在运行时根据具体的对象类型调用相应的方法。
这样可以提高代码的灵活性和可扩展性。
2. 请解释Java中的访问修饰符public、protected、private和default之间的区别。
答案:public修饰的成员变量或方法可以在任何地方被访问;protected修饰的成员变量或方法可以被子类和同一个包内的类访问;private修饰的成员变量或方法只能在当前类中被访问;default修饰的成员变量或方法可以在同一个包内被访问。
java理论试题及答案Java理论试题及答案一、单选题1. Java语言的特点是什么?- A. 面向过程- B. 面向对象- C. 编译型语言- D. 解释型语言答案:B2. 在Java中,用哪个关键字可以定义一个类?- A. `class`- B. `interface`- C. `public`- D. `void`答案:A3. 下列哪个是合法的Java标识符?- A. `class`- B. `default`- C. `2things`- D. `class_name`答案:D4. Java中的继承是单继承还是多继承?- A. 单继承- B. 多继承- C. 既不是单继承也不是多继承- D. 可以是单继承也可以是多继承答案:A5. Java中的异常处理机制是通过哪两个关键字实现的? - A. `try` 和 `catch`- B. `if` 和 `else`- C. `switch` 和 `case`- D. `for` 和 `while`答案:A二、多选题1. 下列哪些是Java的基本数据类型?- A. `int`- B. `String`- C. `double`- D. `char`答案:A, C, D2. 在Java中,下列哪些可以作为方法的返回类型?- A. `int`- B. `void`- C. `String`- D. `double`答案:A, B, C, D3. 下列哪些是Java的访问修饰符?- A. `public`- B. `private`- C. `protected`- D. `default`(无修饰符)答案:A, B, C, D三、判断题1. Java程序的执行都是从`main`方法开始的。
()- 答案:正确2. Java中的所有类都是继承自`ng.Object`类的。
() - 答案:正确3. Java语言支持多重继承。
()- 答案:错误4. `final`关键字修饰的类不能被继承。
1.方法定义和常量值的集合是( )(A).单元(B). 接口(C).成员(D).变量2.下列不属于条件控制语句的是( )(A).for语句(B).if语句(C).if....else语句(D).if语句的扩充形式3.下列说法正确的是( )(A).不需定义类,就能创建对象(B).属性可以是简单变量,也可以是一个对象(C).属性必须是简单变量(D).对象中必有属性和方法4.下面这行代码String [][]s=new String[10][]; 的正确陈述是( )(A).该行代码非法(B).s 是一10行10列的数组(C).s 是一包含10个一维数组的二维数组(D).s中每个元素设为""5.下面不是面向对象技术特点的是( )(A).模块化(B).封装(C).继承性(D).多态性6.下面概念中,不属于面向对象方法的是__ ___.(A).对象(B).继承(C).类(D).过程调用7.下面不是合法Java标识符的是( )(A).ab (B).$3 (C).3ab (D).ab38.接口中的方法被默认是什么的( )(A).private (B).public (C).protected (D).package9.Java语言的编译器命令是( )(A).javac (B).java (C).javaw (D).jar10.下面的不是Java语言特点的是( )(A).动态性(B).面向对象(C).编辑型(D).多线程11.关于实例方法和类方法的区别,下列描述正确的是( )(A).实例方法是不用创建类的实例就可以直接调用(B).类方法是通过static关键字声明的方法(C).实例方法属于类(D).类方法是通过new以后才能调用的方法12.如果只运行别人的Java程序,需要安装的是( )(A).WORD (B).JRE (C).JDK (D).JVM13.使用哪个关键字来定义一个接口( )(A).implements (B).class (C).extends (D).interface14.不是Java关键字的是( )(A).class (B).byte (C).goto (D).import15.一个类中的方法可以被( )(A).左右转换(B).相互调用(C).禁止混合(D).以上全不对16. main()需要一个参数,它是( )(A).一个整型量(B).一个String对象(C).一个实型量(D).一个任意类的对象17.下列不是重载方法的特征的是( )(A).参数个数不同(B).参数名相同而类型不同(C).参数类型不同(D).参数名相同且类型相同18.在Java中,名字必须和它所在的类的名字相同,而且不返回任何数据类型的方法是( )(A).构造方法(B).类方法(C).实例方法(D).重载方法19.不是修饰符的是( )(A).public (B).private (C).protected (D).classng包中的类,该类的实例用来封装对象运行时的状态的是( )(A).Class (B).Object (C).Math (D).Date21.组成java程序的基本要素是( )(A).源代码(B).软件(C).类(D).指令代码22.计算机只能识别执行的指令是( )(A).程序指令(B).代码指令(C).机器指令(D).源文件23.在编写异常处理的Java程序中,每个catch语句块都应该和___ __语句块对应,使得用该语句块来启动Java的异常处理机制.(A).if-else (B).switch (C).try (D).throw24.下面关于继承的描述正确的是__ ___.(A).在Java中只允许单一继承(B).在Java中一个类只能实现一个接口(C).在Java中一个类不能同时继承一个类和实现一个接口(D).Java的单一继承使代码不可靠25.实例可以操作类的( )(A).成员变量(B).成员方法(C).A、B全是(D).A、B全不是26.下列____是异常的含义.(A).程序的语法错(B).程序编译或运行中所发生的异常事件(C).程序预定义好的异常事件(D).程序编译错误27.Java语言有多种实现机制,下列_____技术属于垃圾回收机制.(A).字节编译(B).内存跟踪(C).语法检查(D).堆栈上/下溢检查28.定义一个名为key的类,使之不能被继承,应选(D)(A).class key{} (B).native class key{} (C).class key{ final;} (D).final class key{}29.final关键字不能修饰的参数是( )(A).类(B).成员(C).变量(D).方法30.写类的目的是为了描述一类事物共有的( )(A).属性(B).数量(C).范围(D).源文件31.Java源文件扩展名是( )(A)..class (B)..java (C)..jav (D)..cla32.Java中,一个类可以有父类的个数是( )(A).1 (B).2 (C).3 (D).433类中不加任何访问权限限定的成员属于( )(A).default (B).public (C).private (D).protected34.属于main()方法的返回类型是__ ___.(A).public (B).static (C).void (D).main35.接口体中不应包含( )(A).常量定义(B).常量赋值(C).方法实现(D).方法声明36.在try-catch-finally 结构中,哪个说法不正确( )(A).可以存在多个catch 语句块,表示可以捕捉多种异常(B).不能同时没有catch 语句块和finally 语句块(C).结构整体可以当作一条语句,从而可以嵌套在其他try-catch-finally 结构中(D).在try-catch-finally 结构中,不发生异常,finally 语句块不会执行37在编写Java Application程序时,若需要使用到标准输入输出语句,必须在程序的开头写上_ ___语句.(A).import java.awt.*; (B).import applet.Applet;(C).import java.io.*; (D).import java.awt.Graphics;38.当方法被调用时如果方法有参数,参数必须要( )(A).实例化(B).解析化(C).传递(D).释放39.处理日期的类在Java的哪个包中( )(A).java.util (B).java.io (C)ng (D)39.Java 异常处理涉及的关键字,以下哪个不是( )(A).try (B).final (C).catch (D).throws40.每个Java小应用程序必须定义为___ ___.(A).Applet类或JApplet类的子类(B).JFrame类的子类(C).Frame的子类(D).Windows的子类41.在方法内部使用,代表对当前对象自身引用的关键字是__ ____.(A).super (B).This (C).Super (D).this42.在Java中,由Java编译器自动导入,而无需在程序中用import导入的包是___ ___.(A).java.applet (B).java.awt (C).java.util (D)ng43.有以下方法的定义,请选择该方法的返回类型__ ___.ReturnType method(byte x, float y){ return (short)x/y*2; }(A).byte (B).short (C).int (D).float44.默认情况下,所有类能访问所有成员,除了( )(A).用final关键字定义(B).用abstract定义的(C).在另一个包中定义的(D).在同一个包中定义的45.在Java中下列关于继承的论述中,错误的是( )(A).继承具有传递性(B).继承关系也称为"即是"(is a)关系(C).支持多继承(D).继承提高了系统的可重用性46.Java语言使用的字符集是( )(A).ASCII (B).EBCDIC (C).Unicode (D).BCD47.下面定义形式中,哪一个是非法的( )(A).class A{int a,b;…}(B).clas s A{int i,j; i=j=10…}(C).class A{int i; float f;…} (D).class A{int i=12; float f1=1.2f;…}48.下列关于Java Application和Java Applet程序的差别描述正确的是__ ____.(A).运行方式不同,程序结构相同,运行工具不同,受到的限制相同(B).运行方式相同,程序结构不同,运行工具不同,受到的限制相同(C).运行方式相同,程序结构相同,运行工具不同,受到的限制也不同(D).运行方式不同,程序结构不同,运行工具不同,受到的限制也不同49.Java中管理类的一个机制是( )(A).包(B).语言(C).模块(D).变量50.下列不对的是( )(A).一个实例方法可以同时为protected和abstract (B).static变量也可为final的(C).static方法可以是protected (D).final方法可以是abstract的51.继承是面向对象编程的一个重要特征,它可降低程序的复杂性并使代码_ _____.(A).可读性好(B).可重用(C).可跨包访问(D).运行更安全52.抽象类和接口的共同点是( )(A).代表系统的抽象层(B).都不能被实例化(C).都包含抽象方法(D).以上都对53.关于super,下面说法中错误的是( )(A).用来访问父类被隐藏的的成员变量(B).用于调用父类中被重写的方法(C).用于定义父类(D).用于调用父类的构造函数54.构造方法是一种特殊方法,它的名字必须和__ ___相同,而且不返回任何数据类型.(A).类名(B).对象名(C).包名(D).变量名55.常量定义的修饰符为( )(A).final (B).finally (C).const (D).define56.在成员变量和局部变量重名时,若想在方法内使用成员变量,要使用关键字( )(A).super (B).import (C).this (D).return57.对于异常处理,以下说法哪个正确( )(A).在运行时一旦发现运行时异常,不会中断并退出程序(B).受检异常在编译时不会被检测到(C).受检异常程序必须处理(D).运行时异常在编译时会被检测到58.Java源文件经编译产生的文件称为( )(A)..obj文件(B)..exe文件(C)..java文件(D).字节码文件59.下面定义main()方法有效的是( )(A).public static void main(String args[]){} (B).public main(String[])(C).public void main() (D).public void main(args[]){}60.下列不是构造方法特征的是( )(A).名字和类相同(B).是无参数的(C).是void型(D).是一种特殊方法61.关于main()方法说法正确的是( )(A).一个类中可以没有main() (B).所有对象都必须放在main()方法中(C).main()必须放在公共类中(D).main()方法头的定义可以根据情况任意修改62.保证Java语言可移植性的特征是__ __.(A).面向对象(B).安全性(C).分布式计算(D).可跨平台63.异常处理流程中,以下哪个代码块用来捕获并处理异常( )(A).try (B).catch (C).finally (D).都不是64.接口中的方法默认的访问控制方式是( )(A).public (B).private (C).protected (D).default65.Java异常的处理时,抛出异常可以利用什么语句( )(A).throw (B).try (C).catch (D).throws。
java初级选择试题及答案以下是一份Java初级选择试题及答案的模板:Java初级选择试题一、单选题(每题2分,共40分)1. Java语言的特点包括以下哪一项?- A. 跨平台- B. 编译型语言- C. 动态类型- D. 内存管理答案:A2. 下列哪个关键字用于定义一个接口?- A. class- B. interface- C. abstract- D. enum答案:B3. 在Java中,用于实现多态的机制是什么?- A. 继承- B. 接口- D. 泛型答案:A4. Java中的集合框架中,哪个类用来存储一组不允许重复的元素? - A. ArrayList- B. HashSet- C. LinkedList- D. TreeMap答案:B5. Java中,哪个类是所有异常的超类?- A. Throwable- B. Exception- C. Error- D. RuntimeException答案:A6. 下列哪个操作符用于判断两个对象是否引用同一个对象实例?- A. ==- B. !=- C. =- D. ===答案:A7. Java中,哪个关键字用于抛出异常?- A. try- C. throw- D. finally答案:C8. 在Java中,哪个方法用于获取对象的哈希码? - A. equals()- B. hashCode()- C. clone()- D. toString()答案:B9. Java中,哪个包包含了基本的输入输出功能? - A. java.util- B. java.io- C. ng- D. 答案:B10. 下列哪个是Java的自动垃圾回收机制?- A. JVM- B. JIT- C. GC- D. JIT Compiler答案:C二、多选题(每题3分,共30分)11. 在Java中,哪些是合法的标识符?- A. class- B. $default- C. 2methods- D. _interface答案:B, D12. 下列哪些是Java的基本数据类型?- A. int- B. String- C. float- D. boolean答案:A, C, D13. 在Java中,哪些是合法的主方法的签名?- A. public static void main()- B. public static void main(String[] args) - C. public void main(String args[])- D. public static void main(String args) 答案:B, D14. 下列哪些是Java集合框架中的接口?- A. List- B. Map- C. Set- D. Queue答案:A, B, C15. 在Java中,哪些是合法的数组初始化方式?- A. int[] arr = new int[5];- B. int arr[] = {1, 2, 3};- C. int arr = {1, 2, 3};- D. int[] arr = {1, 2, 3};答案:A, B, D三、判断题(每题1分,共10分)16. Java程序在执行时,首先运行的是main()方法。
1. The name of a Java source file (d)(d) must be the same as the class it defines, respecting case2. Which method must exist in every Java application? (a)(a) main1. Given the following code, how many tokens will be output? (b)StringTokenizer st = new StringTokenizer("this is a test");while (st.hasMoreTokens()) {stdOut.println(st.nextToken() );}(b) 42. Classes from which of the following packages are implicitly imported into every Java program? 答案:(d)(d) ng3. What is the name of the wrapper class for the type int? (d)(d) Integer4. Classes from which of the following packages are implicitly imported into every Java program?(c)(c) ng5. The term wrapper classes refers to (a)(a) a collection of Java classes that "wrap" Java primitive types6. What will be output caused by the execution of the following Java program segment? (c) String name = "Elvis";System.out.print(name + "was here");(c) Elviswas here1. What will be output when the following Java program segment is executed? (c)int x = 5;int y = 2;System.out.println(x + y);(c) 72. A difference between the methods print and println of the class java.io.PrintWriter is that (a)(a) println appends a new line to the end of its output, but print does not3. Consider the following Java program segment. (c)int x = 5;int y = 2;System.out.println(x + "1" + y);Which of the following statements is true about the program segment?(c) The output caused by the code will be 512.1. All Java exception classes are derived from the class (a)(a) ng.Throwable2. In Java, exceptions that are not handled are passed up the (b)(b) call stack3. What is the right way to handle abnormalities in input on Java? (d)(d) By handling these problems by providing exception handlers4. Consider the following Java program segment.import java.io.*;public class SomeClass{public void x() {throw new RuntimeException("Exception from x");}public void y(){throw new IOException("Exception from y");}}Which of the following is true concerning the definitions for the methods x and y? (a)(a) x has a legal definition, but y has an illegal definition.1. Which of the following statements is true of the conventions outlined by Sun Microsystems in the document entitled Code Conventions for the Java Programming Language? (d)They define a standard interface definition language that must be used for all Java classes.They provide recommendations intended to make source code easier to read and understand. They describe one mechanism for network communication between Java and C++ programs. (d) II onlyFeedback: See section 1.1.6, subsection "CodeConvTOC" and section 1.1, subsection "Why Have Code Conventions," in the course notes.2. According to the Java code conventions, files that contain Java source code have the suffix _____, and compiled bytecode files have the suffix _____. (d)(d) .java, .classFeedback: See section 1.1.6, subsection "CodeConvTOC" and section 2.1, subsection "File Suffixes," in the course notes.3. According to the document entitled Code Conventions for the Java Programming Language, file suffixes used by Java software include which of the following? (b).obj.class.h(b) II only1. Which of the following patterns of characters opens a Javadoc comment block? (b)(b) /**1. After a typical debugger encounters a breakpoint, the programmer using the debugger may perform which of the following actions? (a)Examine the values of variables in the halted programExecute the current lineResume execution of the halted program(a) I, II, and III2. In a typical source-code debugger, a programmer can set a _____ to cause a program to stop executing at a particular line of code. (c)(c) breakpoint3. A stack trace is (b)(b) a sequence of method calls4. A tool that allows programmers to execute lines of a program one line at a time in order to help locate the source of a program's errors is known as a(n) (b)(b) debugger1.According to Javadoc convention, the first sentence of each Javadoc comment should be (c) (c) a summary sentence of the declared entryFeedback: See /j2se/javadoc/writingdoccomments/index.html#format for more information.1. In a UML class diagram's representation of a class, the top, middle, and lower rectangular compartments respectively describe the _____ of the class. (c)(c) name, attributes, and methods2. UML class diagrams can describe which of the following? (b)The internal structure of classesRelationships between classes(b) I and II1. Consider the following UML class diagram.According to the diagram, instances of the class named _____ have references to instances of the class named _____. (a)(a) A, B2. Consider the following UML class diagram.According to the diagram, which of the following statements is true? (a)(a) ClassA is composed of one instance of ClassB and one or more instances of ClassC.3. A binary association is said to exist between two classes when (a)(a) an object of one class requires an object of the other class4. The multiplicity of an association between two classes indicates the number of (a)(a) instances of one class that can be associated with an instance of the other class5. Which of the following is true about association and aggregation in UML class diagrams? (c)(c) Aggregation is a special form of association.1. A collection typically models a _____ relationship. (b)(b) one-to-many2. Consider the following UML class diagram. (c)The diagram describes a(c) self-containing class3. Consider the class described by the following diagram:If the class represents an employee and the boss attribute refers to the employee's boss, which of the following statements is (are) true? (c)Many employees can have the same boss.One employee can have many bosses.(c) I only4. Consider the following UML class diagram.Which of the following is (are) true about the system described by the diagram? (d)An instance of Picture can contain a collection of instances of the class Shape.An instance of Shape can contain a collection of instances of the class Picture.(d) I only5. If a class has an association with itself, then the class contains (b)(b) an attribute that references an object of the same class1. An object model describes which of the following? (c)Attributes of classesMethods of classesRelationships between classes(c) I, II, and III2. In an object model, the data that an object is responsible for maintaining are represented by (b)(b) attributes1. A relationship that exists between two specific instances of an object is known as a(n) (b)(b) linkFeedback: See Chapter 5, page 114, in the course textbook.2. The static model of a software system typically includes which of the following? (b) Attributes of classesActions that occur between classesStructural relationships between classes(b) I and III onlyFeedback: See Chapter 10, page 213, in the course textbook.3. Consider the following UML class diagram.According to the diagram, which of the following statements is (are) true? (c)ClassB is a specialization of ClassA.ClassA is a generalization of ClassC.ClassC is involved in a self-containment loop.(c) I, II, and III4. When using noun-phrase analysis to model a software system, which of the following should typically be eliminated from the list of potential classes? (a)References to the software system itselfNouns that imply roles between objectsSynonyms to other nouns in the list(a) I, II, and IIIFeedback: See Chapter 10, page 216-219, in the course textbook.1. The term class variable is a synonym for (c)(c) a static data field1. Which is the Java keyword used to denote a class method? (c)(c) static2. Which of the following statements about class variables in Java is not true? (c)(c) All objects have their own copy of the class variable defined in the instantiated class.3. Which of the following categorizations can be applied to both the data fields and the methods ina Java class? (a)(a) static and non-static1. What is used to indicate that a method does not return a value? (c)(c) the keyword voidFeedback: See chapter 4 of the text.2. The return type for a method that returns nothing to its caller is (c)(c) voidFeedback: See chapter 4 of the text.3. If a class contains a constructor, that constructor will be invoked (c)(c) each time an object of that class is instantiatedFeedback: See chapter 4 of the text.4. If the method int sum(int a, int b) is defined in a Java class C, which of the following methods cannot coexist as a different method in class C? (b)(b) int sum(int x, int y)Feedback: See chapter 5 of the text.5. From within a child class, its parent class is referred to via the keyword (d)(d) superFeedback: See chapter 5 of the text.6. When a subclass defines an instance method with the same return type and signature as a method in its parent, the parent's method is said to be (a)(a) overriddenFeedback: See chapter 5 of the text.7. Consider the following Java class definitions.public class Object1 {protected String d(){return "Hi";}}public class Object2 extends Object1 {protected String d(){return super.d();}}Which of the following statements is (are) true regarding the definitions? (d)Class Object2 inherits from class Object1.Class Object2 overrides method d.Method d returns equivalent results when executed from either class.(d) I, II, and IIIFeedback: See chapters 5 and 13 of the text.8. Consider the following Java program segment.import java.io.*;public class Test {public Test( ) {System.out.println("default");}public Test( int i ) {System.out.println("non-default");}public static void main(String[] args) {Test t = new Test(2);}}Which of the following will be output during execution of the program segment? (a)(a) The line of text "non-default"Feedback: See chapter 13 of the text.9. Which of the following statements about constructors in Java is true? (b)(b) A class can define more than one constructor.Feedback: See chapter 13 of the text.10. Which is a Java access modifier used to designate that a particular data field will not be inherited by a subclass? (c)(c) privateFeedback: See chapter 13 of the text.1. Consider the following Java program segment.int[] arr;arr = new int[3];arr[2]=19;arr[1]=17;arr[0]=15;Which of the following Java statements is syntactically correct and semantically identical to the program segment? (b)(b) int[] arr= {15, 17, 19};2. Consider the Java program below.public class Arr{public static void main(String[] args) {int[] a = {1, 2, 3};System.out.println(a[1]);System.out.println(a[3]);}}Which of the following is true about the result of executing the program? (c)(c) The number 2 is printed and a run-time exception terminates execution.3. If the length of a particular array is the value of LIMIT, what is the index of the last item in that array? (d)(d) LIMIT - 14. Legal Java statements to initialize an array reference include which of the following? (b)int[] aobj = {0, 1, 2};int[4] aobj = {0, 1, 2};int[] aobj = new int[3];(b) I and III only5. A Java array that contains n components will be indexed from _____ through _____. (b)(b) 0, n-16. Consider the following Java program segment.String[] str = {"Three","Two","One"};for (int i = 0; i < str.length; ++i) {System.out.println(str[i]+"/");}What will be output upon execution of the program segment? (d)(d) Three/Two/One/7. Regarding the following declaration, what is the index of the element containing 45? (d)int[] numbers = {-1, 45, 6, 132};(d) 11. Consider the following method call, where c is an instance of the class java.util.ArrayList.c.size();This method call returns the number of (c)(c) elements in the ArrayList represented by c2. An object that contains methods that traverse a collection linearly from start to finish is known as a(n) (a)(a) iterator3. Which of the following statements is not true of the class java.util.ArrayList? (b)(b) Once an object is inserted into an instance of ArrayList, it can never be removed.4. In which of the following ways can items be added to a collection implemented by java.util.ArrayList? (b)Items can be inserted at the beginning of the collection.Items can be inserted between two existing items in the collection.Items can be appended to the end of the collection.(b) I, II, and III5. Which of the following methods is (are) provided by java.util.Iterator? (d)next, which causes an iterator to return the next item in its iterationremove, which can remove an item from a collection associated with an iterator(d) I and II6. The class java.util.ArrayList implements a collection that (c)(c) can grow to accommodate new items1. Which of the following statements is (are) true about any abstract method in Java? (b)It contains no definition.It cannot be declared public.(b) I only2. Which of the following statements is (are) true in Java? (b)Classes that contain abstract methods must be declared abstract.Classes that contain protected methods must be declared abstract.(b) I only3. The subclass of an abstract class must (c)(c) be abstract or implement all of the parent's abstract methods1. Which of the following statements about Java classes is (are) accurate? (c)A class may have only one parent.Two or more classes may share a parent.(c) I and II2. Consider the following Java program fragment.public void drive(Vehicle v) {...}...drive(obj);The method call drive(obj) is valid if obj is which of the following? (a)A descendent of class VehicleAn ancestor of class VehicleAn object of class Vehicle(a) I and III only1. Which of the following statements is (are) true about interfaces in Java? (d)Interfaces can extend other interfaces.Interfaces can contain data fields.(d) I and II2. Which of the following statements is (are) true in Java? (d)An abstract class may contain data fields.Interfaces may contain data fields.(d) I and II3. Which of the following statements is (are) true about inheritance in Java? (c)A class can extend more than one abstract class.A class can implement more than one interface.(c) II only4. Which of the following statements is (are) true about all data fields in an interface in Java? (c) They are implicitly public.They are implicitly final.They are implicitly static.(c) I, II, and III5. Which is the Java keyword that denotes the use of an interface? (d)(d) implements6. Which of the following statements is (are) true in Java? (b)All of the methods in an abstract class must be abstract.All of the methods in an interface must be abstract.(b) II only7. In Java, all methods in an interface must be _____ and _____. (b)(b) public, abstract8. Data fields in an interface implicitly have _____ access in Java. (a)(a) public1. A design pattern is typically used to (c)(c) describe a practical solution to a common design problem1. Consider the following definition of a Java class.public class C {private static C instance = null;private C() {}public static C getInstance() {if (instance == null) {instance = new C();}return C;}}This class is an example of the design pattern (d)(d) Singleton2. The constructor of a class that adheres to the Singleton design pattern must have _____ visibility. (a)(a) private1. In which of the following design patterns is a family of algorithms encapsulated into individual but interchangeable classes? (a)(a) Strategy2. The Strategy design pattern is likely to be useful when implementing which of the following?(a) An application that offers several alternate sorting algorithmsA simple class to store the address of an organization of which only one instance can be instantiated(a) I only1. Consider the following Java program segment. (a)PrintWriter fileOut = new PrintWriter(new FileWriter("output.txt"));If the file output.txt already exists, which of the following events will occur when the program segment is executed?(a) The existing contents of output.txt will be erased.2. If a file opened for reading does not exist, which of the following events will occur in Java? (a)(a) A FileNotFoundException will be raised.1. (1)The model part of the Model-View-Controller (MVC) paradigm embodies the (a)(a) abstract domain knowledge of an application(2)The view part of the Model-View-Controller (MVC) paradigm is the (b)(b) way in which the abstract domain knowledge of an application is presented to the userFeedback: See Chapter 16, page 474, in the course textbook.2. Which of the following is true regarding the controller part in the Model-View-Controller (MVC) paradigm? (a)(a) The controller is the automatic mechanism by which the user interface is displayed and by which events are communicated between the model and the view.Feedback: See Chapter 16, page 475, in the course textbook.3. In Java, the default layout manager for a JPanel component is (c)(c) FlowLayoutFeedback: See Chapter 16, page 494, in the course textbook.4. What is the number of regions into which the BorderLayout in Java subdivides a container? (a)(a) 5Feedback: See Chapter 16, page 494, in the course textbook.5. Which of the following is (are) true regarding event handling in Java? (a)When a GUI component is created, the component automatically has the ability to generate events during user interaction.Each Listener object must be registered with the specific component object or objects for which the Listener object is to respond.(a) I and IIFeedback: See Chapter 16, page 523, in the course textbook.6. Which of the following is a Java event that is generated when a JButton component is pressed? 答案:(b)(b) ActionEventFeedback: See Chapter 16, page 525, in the course textbook.7. The ListSelectionEvent class and ListSelectionListener interface are available in the _____ package of Java. (b)(b) javax.swing.eventFeedback: See Chapter 16, page 525, in the course textbook.8. Which of the following is a Java event that is generated when the close button on a JFrame component is pressed? (b)(b) WindowEventFeedback: See Chapter 16, page 534, in the course textbook.9. In Java, what is the signature of the method in the WindowListener interface where code is to be added to end a program when the close button is pressed? (d)(d) void windowClosing (WindowEvent we)Feedback: See Chapter 16, page 537, in the course textbook.10. What is the signature of the method specified in the Java ListSelectionListener interface? (b)(b) void valueChanged (ListSelectionEvent lse)Feedback: See Chapter 16, page 540, in the course textbook.Given the following code, what value will be output by the last statement?StringTokenizer st = new StringTokenizer("this is,a,test of tokens", ",");String s;int count = 0;while (st.hasMoreTokens()){ s = st.nextToken();++count;}stdOut.println(count);正确答案: C. 3The name of a Java source file正确答案: A. must be the same as the class it defines, respecting caseWhich of the following statements is (are) true about the use of an asterisk (*) in a Java import statement?It does not incur run-time overhead.It can be used to import multiple packages with a single statement.It can be used to import multiple classes with a single statement.正确答案: B. 1 and 3 onlyConsider the following Java program segment.int x = 5; int y = 2; System.out.println(x + "1" + y);Which of the following statements is true about the program segment?正确答案: A. The output caused by the code will be 512.What is the right way to handle abnormalities in input on Java?正确答案: C. By handling these problems by providing exception handlersThe term wrapper classes refers to正确答案: A. a collection of Java classes that "wrap" Java primitive typesFrom within a child class, its parent class is referred to via the keyword正确答案: C. superWhat is used to indicate that a method does not return a value?正确答案: B. the keyword voidWhich of the following statements about constructors in Java is true?正确答案: D. A class can define more than one constructor.When a subclass defines an instance method with the same return type and signature as a method in its parent, the parent's method is said to be正确答案: A. overriddenIf a class contains a constructor, that constructor will be invoked正确答案: B. each time an object of that class is instantiatedWhich is a Java access modifier used to designate that a particular data field will not be inherited by a subclass?正确答案: C. privateConsider the following Java class definitions.public class Object1 {protected String d(){return "Hi";}}public class Object2 extends Object1{protected String d(){return super.d();}}Which of the following statements is (are) true regarding the definitions?Class Object2 inherits from class Object1.Class Object2 overrides method d.Method d returns equivalent results when executed from either class.正确答案: C. I, II, and IIIWhen a subclass defines an instance method with the same return type and signature as a method in its parent, the parent's method is said to be正确答案: A. overriddenIf the method int sum(int a, int b) is defined in a Java class C, which of the following methods cannot coexist as a different method in class C?正确答案: C. int sum(int x, int y)import java.io.*;public class Test {public Test( ) {System.out.println("default");}public Test( int i ){System.out.println("non-default");}public static void main(String[] args) {Test t = new Test(2);}}Which of the following will be output during execution of the program segment?正确答案: C. The line of text "non-default"Consider the Java program below.public class Arr{public static void main(String[] args){int[] a = {1, 2, 3};System.out.println(a[1]);System.out.println(a[3]);}}Which of the following is true about the result of executing the program?正确答案: C. The number 2 is printed and a run-time exception terminates execution.Which of the following methods is (are) provided by java.util.Iterator?next, which causes an iterator to return the next item in its iterationremove, which can remove an item from a collection associated with an iterator正确答案: C. I and IIWhich of the following statements is not true of the class java.util.ArrayList?正确答案:C. Once an object is inserted into an instance of ArrayList, it can never be removed.Regarding the following declaration, what is the index of the element containing 45?int[] numbers = {-1, 45, 6, 132};正确答案: D. 1String[] str = {"Three","Two","One"};for (int i = 0; i < str.length; ++i){ System.out.println(str[i]+"/"); }What will be output upon execution of the program segment?正确答案: C. Three/Two/One/Consider the following method call, where c is an instance of the class java.util.ArrayList.c.size();This method call returns the number of正确答案: C. elements in the ArrayList represented by cConsider the following Java program segment.int[] arr; arr = new int[3]; arr[2]=19; arr[1]=17; arr[0]=15;Which of the following Java statements is syntactically correct and semantically identical to the program segment?正确答案: D. int[] arr= {15, 17, 19};If the length of a particular array is the value of LIMIT, what is the index of the last item in that array?正确答案: A. LIMIT - 1The class java.util.ArrayList implements a collection that正确答案: D. can grow to accommodate new itemsAn object that contains methods that traverse a collection linearly from start to finish is known as a(n)正确答案: C. iteratorUML class diagrams can describe which of the following?1、The internal structure of classes2、Relationships between classes错误!未找到引用源。
j a v a单选题(共11页)--本页仅作为文档封面,使用时请直接删除即可----内页可以根据需求调整合适字体及大小--单选题:1.不符合方法重写规则的是哪个A.方法重写发生在类继承时。
B.子类可以重写一个父类中已有的方法。
C.重写的方法与被重写的方法返回值类型必须一致。
D.重写的方法与被重写的方法参数列表必须不同。
2.读程序,判断在编译时哪行将出错?1) public class Test { 2) int m, n; 3) public Test() {} 4) public Test(int a) { m=a; } 5) public static void main(String arg[]) { 6) Test t1,t2; 7) int j,k; 8) j=0; k=0; 9) t1=new Test(); 10) t2=new Test(j,k); 11) } 12) }A.第3行B.第4行C.第9行D.第10行3.读程序,以下描述哪一个正确?class Base{}class Sub extends Base{}class Sub2 extends Base{}public class Test{ public static void main(String args[]){ Base b = new Base(); Sub s = (Sub) b; }}A.编译出错。
B.编译通过,运行时出错。
C.编译出错,但可以继续运行。
D.程序正常编译和运行。
4.以下的哪个Java源文件代码片断是错误的A.package testpackage; public class Test{...}B.import .*; package testpackage; public class Test{...}C.import .*; class Person{...} public class Test{...}D.import .*; import .*; public class Test{...}5.读程序,选择正确的运行结果class Test{ public static void main(String args[]){ AClass ref1=new AClass(5); AClass ref2=new AClass(10); (ref2); }}class AClass{ private int x; AClass(int x){ =x; } void getAddShow(AClass ref){ "" ""); }}A.有编译错误。
一、单选题(每题2分,共20分)1、Java 属于以下哪种语言?A 、机器语言B 、 汇编语言C 、高级语言D 、以上都不对 2、下面哪种类型的文件可以在Java 虚拟机中运行?A 、.javaB 、.jreC 、.exeD 、.class3、安装好JDK 后,在其bin 目录下有许多exe 可执行文件,其中java.exe 命令的作用是以下哪一种?A 、Java 文档制作工具B 、Java 解释器C 、Java 编译器D 、Java 启动器4、以下关于变量的说法错误的是?A 、变量名必须是一个有效的标识符B 、变量在定义时可以没有初始值C 、变量一旦被定义,在程序中的任何位置都可以被访问D 、在程序中,可以将一个byte 类型的值赋给一个int 类型的变量,不需要特殊声明5、请先阅读下面的代码。
int x = 1; int y = 2;if (x % 2 == 0) { y++; } else { y--; }System.out.println("y=" + y);上面一段程序运行结束时,变量y 的值为下列哪一项?A 、1B 、2C 、3D 、switch 语句6、以下哪个选项可以正确创建一个长度为3的二维数组?A 、 new int [2][3];B 、 new int[3][];C 、 new int[][3];D 、 以上答案皆不对7、下面哪一个是正确的类的声明? DA 、 public void HH {…}B 、 public class Move(){…}C 、 public class void number{}D 、 public class Car {…}8、在以下什么情况下,构造方法会被调用?A 、 类定义时B 、 创建对象时C 、 调用对象方法时D 、 使用对象的变量时9、在Java 中,针对类、成员方法和属性提供了4种访问级别,以下控制级别由小到大依次是( )。
java选择试题及答案# Java选择试题及答案一、单选题1. Java是一种:- A. 编译型语言- B. 解释型语言- C. 汇编语言- D. 机器语言答案:B2. Java的跨平台特性主要依赖于:- A. JRE- B. JVM- C. JDK- D. JIT答案:B3. 下列哪个是Java的基本数据类型?- A. String- B. ArrayList- C. int- D. Object答案:C4. Java中的异常处理是通过以下哪个关键字实现的? - A. if- B. try- C. for- D. switch答案:B5. 下列哪个是Java集合框架中的接口?- A. ArrayList- B. HashSet- C. List- D. Map答案:C6. 在Java中,哪个关键字用于定义一个类? - A. class- B. interface- C. enum- D. package答案:A7. Java中的构造方法:- A. 必须有返回类型- B. 必须与类名相同- C. 不能被继承- D. 可以有参数答案:B8. 以下哪个不是Java的访问修饰符?- A. public- B. protected- C. private- D. global答案:D9. Java中的main方法是:- A. 必须在每个类中定义- B. 程序的入口点- C. 只能被类内部调用- D. 只能调用一次答案:B10. 下列哪个是Java的集合类?- A. String- B. HashMap- C. Object- D. Thread答案:B二、多选题1. Java的垃圾回收机制可以:- A. 回收不再使用的对象- B. 回收内存泄漏- C. 确保内存使用效率- D. 完全防止内存泄漏答案:A, C2. 下列哪些是Java的控制流语句? - A. if-else- B. switch-case- C. for- D. try-catch答案:A, B, C3. Java中的接口可以包含:- A. 常量- B. 方法声明- C. 构造方法- D. 实例方法答案:A, B4. 在Java中,哪些是合法的变量名?- A. 2start- B. _myVar- C. myVar2- D. var答案:B, C, D5. Java中的包装类可以:- A. 将基本数据类型转换为对象- B. 用于集合类- C. 实现多态- D. 用于泛型答案:A, B三、判断题1. Java是面向对象的编程语言。
1. How many bytes of storage are required for an integer of type long in Java? (b)(a) Four(b) Eight(c) Two(d) Three注java中有8种基本类型byte:8位无符号整数short: 16位有符号整数臧廷杰int32位有符号整数long:64(8字节)位有符号整数float:32位单精度浮点数double:64位单精度浮点数char:单个字符使用16位Unicode编码boolean2.The two Boolean literals available in Java are _____ and _____. (d)(a) T, F(b) 0, 1(c) TRUE, FALSE(d) true, false3.Consider the following line of Java code. (c)int x = 1+7*2;What will be the value of x at the end of execution of the line of code?(a) 21(b) 16(c) 15(d) 94.How many lines of output will be produced by the following code fragment?(d)for (int i = 0; i < 4; ++i) {for (int j = 1; j < 3 ; ++j) {stdOut.println(i + j);(a) 10(b) 12(c) 6(d) 85.Which is the Java keyword used to denote a class method? (d)(a) class(b) private(c) final(d) static 6??? According to Javadoc convention, the first sentence of each Javadoc commentshould be (c)(a) an @author tag(b) the order of lines is not important(c) a summary sentence of the declared entry(d) an @version tag7.The coding system used to represent characters in Java is (c)(a) bytecode(b) ASCII(c) Unicode8.Which expression below evaluates to true if and only if x is in the range [0,9] (inclusive)? (a)(a) !(x < 0 || x > 9)(b) 0 < x < 9(c) 0 <= x >= 9(d) x > 0 && x < 99.Which of the following is a valid integer constant declaration? (a)(a) final int SCALE = 10;(b) int final SCALE = 10;(c) final SCALE = 10;(d) int SCALE = 10;10.Which of the following is a valid character literal in Java? (注意字符与字符串的表示) (a)(a) ''(b) "'"(c) "a"(d) '<='11.Which of the following is not equivalent in value to the following expre ssion? (b)flag == false(a) flag != true(b) flag(c) !flag(d) !(flag == true) 臧廷杰12. Which of the following statements is used to exit from a switch statemen t? (a)(a) break;(b) end;(c) exit;(d) default;13.Which of the following is not a legal identifier in Java? (c)(a) first_index(b) $first_index(c) 1index(d) index114.In Java, what is the identifier for the primitive type used to represent a char acter? (b)(a) Character(b) char(c) character(d) Char15.Which of the following is a valid literal of type float in Java? (c)(a) 10.5sp(b) 10.5fp(c) 10.5f(d) 10.5d(b) A class must define at least one constructor.(c) A constructor must be defined as public.(d) A constructor must be defined as static.. 17. According to the document entitledCode Conventions for the Java Programming Language, file suffixes used by Java software include which of the following? (b)I. .objII. .classIII. .h(a) I and II only(b) II only(c) II and III only(d) I and III only18. A stack trace is (c) 臧廷杰(a) a list of variables allocated on a program's stack(b) a fatal error that causes a typical debugger to terminate(c) a sequence of method calls(d) only available through a typical debugger's step into feature注堆栈轨迹:如果你需要打印出某个时间的调用堆栈状态你将产生一个堆栈轨迹。
Java复习题(含答案)一、单选题1、JAVA是1995年由( A )公司发布的A.SUNB.MicrosoftC.borlandD.Fox Software2、在Java中,负责对字节代码解释执行的是 BA. 应用服务器B. 虚拟机C. 垃圾回收器D. 编译器3、设有定义 int i = 6 ;,则执行以下语句后,i 的值为( C )。
i += i - 1;A.10B. 121C. 11D. 1004、编译Java Application 源程序文件将产生相应的字节码文件,这些字节码文件的扩展名为( B )。
A. .javaB. .classC. .hD. .c5、定义一个类,必须使用的关键字是( B )A. publicB. classC. staticD. interface6、JAVA中不属于基本数据类型的是 ( C )。
A.StringB.intC.charD.boolean7、 0.6332的数据类型是(B)A. floatB. doubleC. FloatD. Double8、关于类和对象的叙述正确的是:( D )A.类是对象的实例化B.类的静态属性和全局变量的概念完全一样,只是表达形式不同C.类的成员至少有一个属性和一个方法D.Java的类分为两大部分:系统定义的类和用户自定义的类9、void 的含义:( C )A.方法体为空B.定义的方法没有形参C.定义的方法没有返回值D.方法的返回值不能参加算术运算10、设 x = 2 , y = 4 , z = 5,则表达式 y*=z--/++x 的值是( C )A. 3B. 3. 5C. 4D. 511、访问权限最小的控制符是( D )。
A. publicB. protectedC. defaultD. private12、编译Java程序的命令是( B )A. cmdB. javacC. javaD. javadoc13、下列程序test类中的变量c的最后结果为( D ) public class test{public static void main(String args[]){int a = 10;int b;int c;if(a>50){b = 9;}c = b + a;}}A. 10B. 0C.19D.编译错误14、下列不属于面向对象编程的三个特征为( B )A.封装B.指针操作C.多态性D.继承15、下面程序定义了一个类,关于该类说法正确的是 ( A` )Abstract class abstractClass{……}A.该类能调用 new abstractClass(),实例化为一个对象B.该类不能被继承C.该类的方法都不能被重载D.以上说法都不对16、System.out.println(“5”+2);的输出结果是( A )A. 52B. 7C. 2D. 517、下面哪些是合法的标示符( A )A. $perB. 123C. *pointD. this18、定义常量时需要用到的关键字是( C )。
单选题1、Java属于以下哪种语言?(C)A、机器语言B、汇编语言C、高级语言D、以上都不对2、在JDK安装目录下,用于存放可执行程序的文件夹是?AA、binB、jreC、libD、db3、下列Java命令中,哪一个可以编译HelloWorld.java文件?DA、java HelloWorldB、java HelloWorld.javaC、javac HelloWorldD、javac HelloWorld.java4、以下关于java命令作用的描述中,正确的是AA、它专门负责解析由Java编译器生成的.class文件B、它可以将编写好的Java文件编译成.class文件C、可以把文件压缩D、可以把数据打包5、下面关于配置path环境变量作用的说法中,正确的是(A )A、在任意目录可以使用javac和java命令B、在任意目录下可以使用class文件C、在任意目录可以使用记事本D、在任意目录下可以使用扫雷游戏6、下面关于path和classpath的说法中,错误的是(C)A、path用来指定 java 虚拟机(JVM) 所在的目录B、classpath用来指定我们自己所写的或要用到的类文件(.jar文件) 所在的目录C、在dos命令行中,classpath和path环境变量的查看与配置的方式不相同D、只要设置了classpath 这个环境变量系统就不会再在当前目录下查询某个类7、下面关于classpath的说法中,错误的是(D)。
A、classpath和path环境变量的查看与配置的方式完全相同。
B、为了让Java虚拟机能找到所需的class文件,就需要对classpath环境变量进行设置。
C、从JDK5.0开始,如果classpath环境变量没有进行设置,Java虚拟机会自动将其设置为“.”,也就是当前目录。
D、在命令行窗口中配置了classpath后,重新打开新命令行窗口依然生效8、下面哪种类型的文件可以在Java虚拟机中运行?(D)A、.javaB、.jreC、.exeD、.class9、阅读下段代码片段,选择正确的运行结果Apublic static void main(String[] args) {{int a = 1;System.out.print(a);}{int a = 2;System.out.print(a);}int a = 3;System.out.print(a);}A、123B、111C、121D、编译不通过10、下面选项中,哪个是短路与运算符( B )A、&B、&&C、|D、||11、关于表达式1234/1000 * 1000的运算结果,下列哪个选项是正确的(B )A、1234B、1000C、1234.0D、以上都不对12、下面的运算符中,用于执行除法运算是哪个?AA、/B、\C、%D、*13、以下哪个选项可以正确创建一个长度为3的二维数组(B )A、new int [2][3];B、new int[3][];C、new int[][3];D、以上答案都不对14、下列选项中,不属于比较运算符的是AA、=B、==C、<D、<=15、下列选项中,用于引入包的关键字是BA、classB、importC、packageD、static16、下列选项中,哪一个不能通过编译(D )A、byte a=1;B、short b=100;C、int c='a';D、long d=8888888888;17、下列选项中,哪一个是多行注释符号?(D )A、//* *//B、/* /*C、/ /D、/* */18、为了能让外界访问私有属性,需要提供一些使用( C )关键字修饰的公有方法。
A、voidB、defaultC、privateD、public19、下列修饰符中,哪个修饰内部类后,会使内部类会随着外部类的加载而加载。
AA、staticB、protectedC、publicD、private20、阅读下列的程序class Person{static{System.out.println(name);}private static String name = "hello";}class Demo{public static void main(String[] args){Person p = null;}}下列关于程序运行结果的描述中,正确的是(D)A、无结果输出B、输出 nullC、输出 helloD、编译失败21、当一个类中成员变量和局部变量重名时,可以使用哪个关键字进行区分( B )A、superB、thisC、publicD、true22、请阅读下面的程序,选择正确的运行结果。
Aclass Demo{private static int x ;public static void main(String[] args){System.out.println(x++);}}A、0B、1C、无结果D、编译失败23、下列关于构造方法的描述,错误的是( A )。
A、一个类中只能定义一个构造方法B、一个类中可以定义多个构造方法C、如果在一个类中定义有参的构造方法,jvm就不会提供默认的无参构造方法D、构造方法的作用是用来给属性进行初始化的A、一个类中只能定义一个空参数的构造方法B、一个类中可以定义多个构造方法C、如果在一个类中定义有参的构造方法,jvm就不会提供默认的无参构造方法D、构造方法的作用是给属性初始化24、下列修饰符中,成员内部类被( C )修饰后,可以被外界访问。
A、defaultB、protectedC、publicD、private25、下列关于类与对象的说法中,正确的是(C )A、类可以看做是一个模型,可以用来创建对象B、没有类,也可以创建对象C、类是对某一类事物的抽象描述,而对象用于表示现实中该类事物的个体D、以上说法都不对26、在以下什么情况下,构造方法会被调用?BA、类定义时B、创建对象时C、调用对象方法时D、使用对象的变量时27、“隐藏对象的属性和实现细节,仅对外提供公有的方法”描述的是面向对象的哪个特征( A )A、封装B、继承C、多态D、以上都不是28、下列关键字中,用于创建类的实例对象的是( B )。
A、classB、newC、privateD、void29、下列关于匿名内部类的描述,错误的是( D )A、匿名内部类是内部类的简化形式B、匿名内部类的前提是必须要继承父类或实现接口C、匿名内部类的格式是"new 父类(参数列表) 或父接口(){}"D、匿名内部类可以有构造方法30、自定义运行时异常,必须继承自( C )类A、ErrorB、ExceptionC、RuntimeExceptionD、Throwable31、在下面哪种情况下,可以使用方法重写?( C )A、父类方法中的形参不适用于子类使用时B、父类中的方法在子类中没有时C、父类的功能无法满足子类的需求时D、父类方法中的返回值类型不适合子类使用32、下列选项中,用于解压jar文件的命令是( B )A、jar –cB、jar -xC、jar -vD、jar -f33、在try{}catch(______e){}横线处需要填写的是( B )A、异常对象B、异常类D、任意类34、System类位于以下哪个包中?DA、java.ioB、java.utilC、java.awtD、ng35、final修饰符不可以修饰如下哪个内容?(B)A、类B、接口C、方法D、变量36、Java中所有的类都是通过直接或间接地继承( A )类得到的A、ng.ObjectB、ng.ClassC、任意类D、以上答案都不对37、在Java语言中,以下哪个关键字用于在方法上声明抛出异常?CA、tryB、catchC、throwsD、throw38、类中的一个成员方法被下面哪个修饰符修饰,该方法只能在本类被访问?CA、publicB、protectedC、privateD、default39、Thread类位于下列哪个包中?BA、java.ioB、ngC、java.utilD、java.awt40、线程调用sleep()方法后,该线程将进入以下哪种状态?CB、运行状态C、阻塞状态D、死亡状态41、下列方法中,用于判断字符串是否相等的是(C)A、boolean contains(CharSequence cs)B、String toLowerCase()C、boolean equals(Object anObject)D、boolean isEmpty()42、下列关于System类中getProperties()方法的描述中,正确的是?(A)A、getProperties()方法用于获取当前的操作系统的属性B、getProperties()方法用于获取当前JVM的属性C、getProperties()方法用于获取指定键指示的操作系统属性D、getProperties()方法用于获取指定的JVM的属性A、getProperties()方法用于获取当前的操作系统的属性B、getProperties()方法用于获取当前JVM的属性C、getProperties()方法用于获取指定键指示的操作系统属性D、getProperties()方法用于获取指定的JVM的属性43、下列是Math类中的一些常用方法,其中用于获取大于等于0.0且小于1.0的随机数的方法是?(A )A、random()B、abs()C、sin()D、pow()44、下列是Random类的一些常用方法,其中能获得指定范围随机数的方法是?( D )A、nextInt()B、nextLong()C、nextBoolean()D、nextInt(int n)45、下列关于包装类的描述中,错误的是?(D)A、包装类的作用之一就是将基本类型包装成引用类型B、包装类它可以完成在基本类型与String类型之间的转换C、包装类一共有八个,对应的基本数据类型D、可以通过继承包装类完成自定义包装类的设计46、下列关于Date类的描述中,错误的是?( D )A、Date类获取的时间是以1970年1月1日0时0分0秒开始计时的B、在JDK1.1之后,Date类逐渐被Calendar类取代C、Date类中大部分构造方法都被声明为已过时D、Date类中大部分方法依然推荐使用47、下列关于DateFormat中parse(String source)方法的说法中错误的是?( C )A、能够将一个字符串解析成Date对象B、要求字符串必须符合日期/时间的格式要求C、返回值是字符串类型的日期D、执行该方法需要处理ParseException异常48、在DateFormat类中定义了四个常量值用于作为参数传递给这些方法,其中FULL常量表示?(A )A、完整格式B、长格式C、普通格式D、短格式49、在进行日期格式化时,代表秒的字母是?( A )A、sB、SC、MD、m50、是打发AA、1B、2C、3D、451、下列关于Java特点的描述中,错误的是?CA、Java语言不支持指针B、Java具有自动垃圾回收的机制C、Java只能运行在Window和Linux平台D、Java允许多个线程同时执行52、下列关于JDK、JRE和JVM关系的描述中,正确的是DA、JDK中包含了JRE,JVM中包含了JRE。