傻大方


首页 > 知识库 > >

Java|Java题库-175道选择题


按关键词阅读: 题库 java 选择题 175

1、Java程序设计理论题库选择题(单选175题)1.欲构造ArrayList类的一个实例 , 此类继承了List接口 , 下列哪个方法是正确的 ? BA、 ArrayList myList=new Object(); B、 List myList=new ArrayList(); C、 ArrayList myList=new List(); D、 List myList=new List();2.paint()方法使用哪种类型的参数? AA、 Graphics B、 Graphics2D C、 String D、 Color3.指出正确的表达式 DA、 byte=128;
/byte取值到127B、。

2、Boolean=null;
C、 long l=0xfffL;
D、 double=0.9239d;
4.指出下列程序运行的结果 Bpublic class Example String str=new String(good);
charch=a,b,c;
public static void main(String args) Example ex=new Example();
ex.change(ex.str,ex.ch);
System.out.print(ex.str+ and );
Sytem.out.print(ex.ch);
public void change(String。

3、str,char ch) str=test ok;
ch0=g;
A、 good and abc B、 good and gbc C、test ok and abc D、 test ok and gbc 5.运行下列程序, 会产生什么结果 C Dpublic class X extends Thread implements Runable public void run() System.out.println(this is run();
public static void main(String args) Thread t=new Thread(new X();
t.start();


4、 A、 第一行会产生编译错误 B、 第六行会产生编译错误 C、 第六行会产生运行错误 D、 程序会运行和启动 6.要从文件 file.dat文件中读出第10个字节到变量C中,下列哪个方法适合? AA、 FileInputStream in=new FileInputStream(file.dat);
in.skip(9);
int c=in.read();
B、 FileInputStream in=new FileInputStream(file.dat);
in.skip(10);
int c=in.read();
C、 FileInputStream in=new FileInputSt 。

5、ream(file.dat);
int c=in.read();
D、 RandomAccessFile in=new RandomAccessFile(file.dat);
in.skip(9);
int c=in.readByte();
7.容器被重新设置大小后 , 哪种布局管理器的容器中的组件大小不随容器大小的变化而改变? BA、 CardLayout B、 FlowLayout C、 BorderLayout D、 GridLayout 8.给出下面代码: public class Person static int arr = new int10;
public static void m 。

6、ain(String a) System.out.println(arr1);
那个语句是正确的? CA、 编译时将产生错误; B、 编译时正确 , 运行时将产生错误; C 、输出零; D、 输出空 。
9.哪个关键字可以对对象加互斥锁? BA、 transient B synchronized C serialize D static 10.下列哪些语句关于内存回收的说明是正确的? BA、 程序员必须创建一个线程来释放内存; B、 内存回收程序负责释放无用内存 C、内存回收程序允许程序员直接释放内存 D、内存回收程序可以在指定的时间释放内存对象 11.下列代码哪几行会出错: C1) public。

7、void modify() 2) int I, j, k;
3) I = 100;
4) while ( I 0 ) 5) j = I * 2;
6) System.out.println ( The value of j is + j );
7) k = k + 1;
8) I-;
9) 10 A、 line 4 B、 line 6 C、 line 7 D、 line 812.MAX_LENGTH是int型public成员变量, 变量值保持为常量100 , 用简短语句定义这个变量 。
DA、 public int MAX_LENGTH=100;
B、 final int MAX_LENGTH=10 。

8、0;
C、 final public int MAX_LENGTH=100;
D、 public final int MAX_LENGTH=100. 13.给出下面代码:1) class Parent 2 private String name;
3 public Parent() 4 5) public class Child extends Parent 6 private String department;
7 public Child() 8 public String getValue() return name;
9 public static void main(String。

9、arg) 10 Parent p = new Parent();
11 12 那些行将引起错误? DA、 第3行 B、 第6行 C、 第7行 D、 第8行14.类Teacher和Student是类Person的子类; Person p;
Teacher t;
Student s;
/p, t and s are all non-null. if(t instanceof Person) s = (Student)t;
最后一句语句的结果是: B CA、 将构造一个Student对象; B、 表达式是合法的; C、 表达式是错误的; D、 编译时正确 , 但运行时错误 。
15.给出下面代码段 1)。

10、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) 哪行将引起一个编译时错误? DA、 line 3 B、 line 5 C、 line 6 D、 line 10 16.对于下列代码: 1) class Person 2) public void。

11、printValue(int i, int j) /. 3) public void printValue(int i)/. 4) 5) public class Teacher extends Person 6) public void printValue() /. 7) public void printValue(int i) /. 8) public static void main(String args) 9) Person t = new Teacher();
10) t.printValue(10);
11) 第10行语句将调用哪行语句?? DA、 line 2 B、 lin 。

12、e 3 C、 line 6 D、 line 717.哪个关键字可以抛出异常? CA、 transient B、 finally C、 throw D、 static 18.Main()方法的返回类型是: BA、 int B、 void C、 boolean D、 static 19.System类在哪个包中? DA、 java.util B、 java.io C、 java.awt D、 java.lang20.对于下列代码: public class Parent public int addValue( int a, int b) int s;
s = a+b;
return s;
cla 。

13、ss Child extends Parent 下述哪些方法可以加入类Child? CA、 int addValue( int a, int b )/ do something. B、 public void addValue (int a, int b )/ do something. C、 public int addValue( int a )/ do something. D、 public int addValue( int a, int b )throws MyException /do something. 21.给出下面代码: public class test static。

14、int a = new a10;
public static void main(String args) System.out.println(a10);
那个选项是正确的? AA、 编译时将产生错误; B、 编译时正确 , 运行时将产生错误; C、 输出零; D、 输出空 。
22.下面哪些选项是正确的main方法说明? BA、 public main(String args) B、 public static void main(String args) C、 private static void main(String args) D、 void main() 23.给定下面的代码片段:。

15、C1) String str = null;
2) if (str != null) & (str.length() 10) 3) System.out.println(more than 10);
4) 5) else if (str != null) & (str.length() 2)5D、(23)40. 下面哪个是对字符串String的正确定义 ( A )A、String s1=null;
B、String s2=null ;
C、String s3=(String) abc ;
D、String s4=(String) uface;
41. 下面哪条语句不能定义一个float型的变量( B。

16、)A、float f1= -343 ;
B、float f2=3.14 ;
C、float f3=0x12345 ;
D、float f4=2.8F ;
42. 下面哪条语句定义了5个元素的数组( A )A、int a=22,23,24,25,12;
B、int a =new int(5);
C、int 5 array;
D、int arr;
43. 下面哪个范围是char型的取值范围( c )A、-256 255B、-(215) (215)-1C、u0000 uffffD、0327644. 给出一段程序 , 选择运行结果( D )public class sss public static void main 。

17、(String args)String s1=args1;
String s2=args2;
String s3=args3;
String s4=args4;
System.out.println(“args2=”+s2);
命令行执行: java sss 1 2 3 4 结果是下面哪一个?A、args2=2B、args2=nullC、args2=1D、运行出现异常45. 下面哪个描述是正确的( A )A、Applet程序中不需要main()方法 , 也不能有B、Application程序中可以没有main()方法 。
C、Applet程序中可以不定义init( )方法D、Application程序中必须 。

18、有run( )方法46. 给出一段程序 , 试判断哪个是正确的结果( B )public class rtExceptpublic static void throwit()System.out.print(“throwit”);
throw new RuntimeException();
public static void main(String aa)trySystem.out.print(“hello “);
throwit();
catch(Exception re)System.out.print(“caught ”);
finallySystem.out.print(“finally。

19、”);
System.out.print(“after ”);
A、hello throwit caughtB、hello throwit caught finally after C、hello throwit RuntimeException afterD、hello throwit caught finally after RuntimeException47. 对一个java源文件 aaa.java , 编辑保存后但未编译 , 在其所在目录下执行 java aaa , 则接着会出现什么( C )A、error: cannot read: aaa.javaB、无任何显示C、Exception in t 。

20、hread main java.lang.NoClassDefFoundError: aaaD、程序正常执行并显示48. 编译java程序时出现error: cannot read: aaa.java , 则下列原因最正确的是( A )A、原因是执行的当前目录下没有找到aaa.java文件 。
B、原因是没有安装JDK开发环境 。
C、原因是java源文件名后缀一定是以 .txt 结尾 。
D、原因是JDK安装后没有正确设置环境变量PATH和Classpath。
49. 给出一段程序 , 试判断哪个是正确的结果( D )public class myprogrampublic static void main ( 。

21、String args)trySystem.out.print(“Hello world ”);
finallySystem.out.println(“Finally executing”);
A、无法编译 , 因为没有指定异常B、无法编译 , 因为没有catch子句C、Hello worldD、Hello world Finally executing50. 下面哪个是Java语言中正确的标识符( B )A、3DB、$thisC、extendsD、implements51. 下面哪个范围是char型的取值范围( C )A、-256 255B、-(215) (215)-1C、u0000 uffffD、 。

22、03276752. 下面哪个语句不能定义一个字符变量( D )A、char c1=3210;
B、char c2=uface ;
C、char c4=0xabcd ;
D、char c3=”u0065”;
53. 下面哪个是对字符串String的正确定义 ( A )A、String s1=”nt null”;
B、String s2=null ;
C、String s3=(String) abc ;
D、String s4=(String) uface;
54. 给出下面一段程序 , 选择运行结果( C )public class Xpublic static void main(String args)Stri 。

23、ng names=new String5;
for(int x=0;
x 0 ) 5) j = I * 2;
6) System.out.println ( The value of j is + j );
7) k = k + 1;
8) I-;
9) 10 A、 line 4 B、 line 6 C、 line 7 D、 line 8 81、数组中可以包含什么类型的元素?____D_______ 。
A、int型 B、 string型 C、数组 D、 以上都可以82、为AB类的一个无形式参数无返回值的方法method书写方法头 , 使得使用类名AB作为前缀就可以调用它 , 该方法头的形式为( B ) 。
A. 。

24、 static void method( ) B. public void method( ) C. final void method( ) D. abstract void method( )83、编译Java Application 源程序文件将产生相应的字节码文件 , 这些字节码文件的扩展名为( B ) 。
A. .java B. .classC. .html D. .exe84、如果类中的成员变量可以被同一包访问 , 则使用如下哪个约束符? DA、 private B、public C、protected D、no modifier85、以下哪个方法用于定义线程的执行体? AA、 start() 。

25、 B、init() C、run() D、main()86.MAX_LENGTH是int型public成员变量, 变量值保持为常量100 , 用简短语句定义这个变量 。
DA、 public int MAX_LENGTH=100;
B、 final int MAX_LENGTH=100;
C、 final public int MAX_LENGTH=100;
D、 public final int MAX_LENGTH=100.87.给出下面代码:1) class Parent 2 private String name;
3 public Parent() 4 5) public class Chi 。

26、ld extends Parent 6 private String department;
7 public Child() 8 public String getValue() return name;
9 public static void main(String arg) 10 Parent p = new Parent();
11 12 那些行将引起错误? DA、 第3行 B、 第6行 C、 第7行 D、 第8行88.类Teacher和Student是类Person的子类; Person p;
Teacher t;
Student s;
/p, t and s are all no 。

【Java|Java题库-175道选择题】27、n-null. if(t instanceof Person) s = (Student)t;
最后一句语句的结果是: CA、 将构造一个Student对象; B、 表达式是合法的; C、 表达式是错误的; D、 编译时正确 , 但运行时错误 。
89.给出下面代码段 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 T 。

28、est();
10) t2=new Test(j,k);
11) 12) 哪行将引起一个编译时错误? DA、 line 3 B、 line 5 C、 line 6 D、 line 10 90.对于下列代码: 1) class Person 2) public void printValue(int i, int j) /. 3) public void printValue(int i)/. 4) 5) public class Teacher extends Person 6) public void printValue() /. 7) public void printValue(int 。

29、 i) /. 8) public static void main(String args) 9) Person t = new Teacher();
10) t.printValue(10);
11) 第10行语句将调用哪行语句?? DA、 line 2 B、 line 3 C、 line 6 D、 line 791.哪个关键字可以抛出异常? CA、 transient B、 finally C、 throw D、 static 92.Main()方法的返回类型是: BA、 int B、 void C、 boolean D、 static 93.System类在哪个包中? DA、 java. 。

30、util B、 java.io C、 java.awt D、 java.lang94.对于下列代码: public class Parent public int addValue( int a, int b) int s;
s = a+b;
return s;
class Child extends Parent 下述哪些方法可以加入类Child? cA、 int addValue( int a, int b )/ do something. B、 public void addValue (int a, int b )/ do something. C、 public int addVal 。

31、ue( int a )/ do something. D、 public int addValue( int a, int b )throws MyException /do something. 95.给出下面代码: Apublic class test static int a = new a10;
public static void main(String args) System.out.println(arr10);
那个选项是正确的? A、 编译时将产生错误; B、 编译时正确 , 运行时将产生错误; C、 输出零; D、 输出空 。
96.下面哪些选项是正确的main方法说明? BA 。

32、、 public main(String args) B、 public static void main(String args) C、 private static void main(String args) D、 void main() 97.Java语言具有许多优点和特点 , 下列选项中 , 哪个反映了Java程序并行机制的特点(B) A 安全性 B 多线程C 跨平台 D 可移植 98.下列哪个类声明是正确的(D) A abstract final class H1 B abstract private move() C protected private number; D public。

33、abstract class Car 99.下列关于for循环和while循环的说法中哪个是正确的(D) A while循环能实现的操作 , for循环也都能实现 B while循环判断条件一般是程序结果 , for循环判断条件一般是非程序结果 C 两种循环任何时候都可替换 D 两种循环结构中都必须有循环体 , 循环体不能为空 100.异常包含下列哪些内容(C) A 程序中的语法错误 B 程序的编译错误 C 程序执行过程中遇到的事先没有预料到的情况 D 程序事先定义好的可能出现的意外情况 101.Character流与Byte流的区别是(C) A 每次读入的字节数不同 B 前者带有缓冲 , 后者没有 C 前者是块 。


    来源:(未知)

    【学习资料】网址:/a/2021/0121/0021124008.html

    标题:Java|Java题库-175道选择题


    上一篇:长方体|z长方体和正方体的表面积教案

    下一篇:关于个人承诺书四篇