Java总复习

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

运行下列程序, 会产生什么结果 public 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(); } } A 第一行会产生编译错误 B 第六行会产生编译错误 C 第六行会产生运行错误 D 程序会运行和启动
给出下面代码: public class Person{ static int arr[] = new int[10]; public static void main(String a[]) { System.out.println(arr[1]); } } 那个语句是正确的? A 编译时将产生错误; B 编译时正确,运行时将产生错误; C 输出零; D 输出空。
编译java Applet源程序文件将产生相应的结果文 件,这些结果文件的扩展名是什么? A. .java B. .class C. .html D. .exe
现在有两个类:Person与Chinese,Chinese试图 继承Person类,如下项目中哪个是正确的写法? A. class Chinese extents Person{} B. class Chinese extants Person{} C. class Chinese extends Person{} D. class Chinese extands Person{}
对成员的访问控制保护最强的是( )。 A、public 、B、缺省、 C private D protected
MyClass类定义如下: class MyClass{ public MyClass(int x){ } } 如下方式创建对象,哪些是正确的 ? A. MyClass myobj=new MyClass; B. MyClass myobj=new MyClass( ); C. Myclass myobj= new MyClass(1); D. MyClass myobj=new MyClass(1,2);
给定下列代码: 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 arg[]){ 10 Parent p = new Parent(); 11 } 12 } 上述代码的那些行将会导致错误? A. line 3 B. line 6 C. line 7 D. line 8 E. line 10
JPanel组件的默认布局管理器是哪一项? A. GridLayout B. CardLayout C. BorderLayout D. FlowLayour
下面程序的输出结果是。 public class ex2 { public static void main(String[] args) { for(int cnt=0;cnt<10;cnt++) { if(cnt==5) { break; } System.out.print(cnt); } } } A. 0 1 2 3 4 B. 6 7 8 9 C. 0 1 2 3 4 6 7 8 9 D. 5
MAX_LENGTH是int型public成员变量, 变量值保 持为常量100,用简短语句定义这个变量。 A 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.
按照见名知义的原则,String型变量address的一 种规范的命名应该是( )。 A. StrAddress B. straddress C. stringAddress D. strAddress
在Java程序中,处理异常不经过如下哪个阶段 ( )。 A. 抛出异常 B. 捕获异常 C. 处理异常 D. 退出异常
类Teacher和Student是类Person的子类; Person p; Teacher t; Student s; if(t instanceof Person) { s = (Student)t; } 最后一句语句的结果是: A 将构造一个Student对象; B 表达式是合法的; C 表达式是错误的; D 编译时正确,但运行时错误。
下列各种java中的方法的定义,那种是正确的? A. void myFun(int X=1){ } B. void myFun(int & X){ } C. void myFun(int X ){ } D. void myFun(int * X){ }
设Derived类为Base类的子类,则如下对象的创 建语句中那些是错误的? A. Base Obj=new Derived(); B. Derived Obj=new Base(); C. Base Obj=new Base(); D. Derived Obj=new Derived();
下面的表达式哪个是正确的? A String s="你好";int i=3; s+=i; B String s="你好";int i=3; if(i==s){ s+=i}; C String s="你好";int i=3; s=i+s; D String s="你好";int i=3; s=i+; - 9 E. String s=null; int i=(s!=null)&&(s.length>0)?s.length():0;
指出正确的表达式 A byte=128; B Boolean=null; C long l=0xfffL; D double=0.9239d;
下列那种java组件为容器组件 A. List列表框 B. Choice下拉式列表框 C. Panel面板 D. MenuItem 命令式菜单项
如下那种Java的控件将不会引发动作事件 (ActionEvent)? A. Button B. MenuItem C. Panel D. CheckboxMenuItem
哪个关键字可以抛出异常? A transient B finally C throw D static
Main()方法的返回类型是: A int B void C boolean D static
欲构造ArrayList类的一个实例,此类继承了List接 口,下列哪个方法是正确的? A ArrayList myList=new Object(); B List myList=new ArrayList(); C ArrayList myList=new List(); D List myList=new List();
下面哪种注释方法能够支持javadoc命令: A /**...**/ B /*...*/ C // D /**...*/
下列代码执行的结果是? public class text { public static void main(String[] args) { int x= 1, y = 6; while (y--==6) {x--;} System.out.println("x=" + x +" ,y =" + y); } } A. 程序能运行,输出结果:x=0,y=5 B.程序能运行,输出结果:x=-1,y=4 C.程序能运行,输出结果:x=0,y=4 D. 程序不能编译
以下题目多选
执行下列代码后,哪个结论是正确的 String[] s=new String[10]; A s[10] 为 ""; B s[9] 为 null; C s[0] 为未定义 D s.length 为10
下面哪些不是java的基本数据类型? A. short B. Boolean C. Int D. float
Java总复习
下列语句的输出结果为( )。 int a=10, b=6; boolean c=true; System.out.println((a>b)&&(!c)) A. 1 B. 0 C. true
D. false
下列的变量定义百度文库句中,合法的是()。 A. float $_*9=8.4f B. double d=Double.MAX_VALUE; C. int i=3214L D. byte b=12345;
下列代码哪几行会出错: 1) public 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 8
下面哪个方法可以在任何时候被任何线程调用? A notify() B wait() C notifyAll() D sleep() E.yield() F.synchronized(this)
给出下列代码: switch(x){ case 1:System.out.println(“Test 1”);break; case 2: case 3:System.out.println(“Test 2”);break; default:System.out.println(“end”); } x为什么值时,会输出Test 2 ? A. 0 B. 1 C. 2 D. 3
"result"是一个boolean型的变量,下面的哪些表 达式是合法的? A. result = true; B. if ( result ) { // do something... } C. if ( result!= 0 ) { // so something... } D. result = 1
给定下面的代码片段: 1) 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() < 5)) { 6) System.out.println("less than 5"); 7) } 8) else { System.out.println("end"); } 哪些行会导致错误? A line 1 B line 2 C line 5 D line 8
下列哪个方法可用于创建一个可运行的类? A public class X implements Runable { public void run(){ ......} } B public class X implements Thread { public void run(){ ......} } C public class X implements Thread { public int run(){ ......} } D public class X implements Runable { protected void run(){ ......} } E.public class X implements Thread { public void run(){ ......} }
相关文档
最新文档