Java复习重点!!.doc_第1页
Java复习重点!!.doc_第2页
Java复习重点!!.doc_第3页
Java复习重点!!.doc_第4页
Java复习重点!!.doc_第5页
已阅读5页,还剩1页未读 继续免费阅读

下载本文档

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

文档简介

1、写结果class StringTest1public static void main(String args) String s1=hello;String s2=new String(hello);if(s1.equals(s2)System.out.println(相等);elseSystem.out.println(不相等);或者public class IfTest public static void main(String args) int x=3; int y=1; if(x=y) System.out.println(Not equal); else System.out.println(Equal); 2、写结果public class TestArray public static void main(String args ) int i , j ;int a = 5,9,6,8,7; for ( i = 0 ; i a.length-1; i + ) int k = i; for ( j = i ; j a.length ; j+ ) if ( ajak ) k = j; int temp =ai; ai = ak; ak = temp; for ( i =0 ; ia.length; i+ ) System.out.print(ai+ ); System.out.println( ); 3、写出以下程序的功能。import java.io.*;public class TestFile public static void main(String args) throws Exception BufferedReader br=new BufferedReader(new InputStreamReader(System.in); BufferedWriter bw = new BufferedWriter(new FileWriter(“input.txt); String s; while (true) System.out.print(请输入一个字符串: ); System.out.flush(); s=br.readLine(); if (s.length()=0) break; bw.write(s); bw.newLine(); bw.close(); 4、写出结果class Animal Animal() System.out.print (Animal ); public class Dog extends Animal Dog() System.out.print (Dog ); public static void main(String args) Dog snoppy= new Dog(); 5、下面程序是实现采用JDBC-ODBC的数据库连接,连接数据数据源table1,并实现查询功能,请在适当的位置填写语句。class Conn String sDBDriver = _; String sConnStr = jdbc:odbc:table1; Connection connect = null; ResultSet rs = null; public Conn() try _(sDBDriver); catch(java.lang.ClassNotFoundException e) System.err.println( e.getMessage(); public ResultSet executeQuery(String sql) try connect = DriverManager.getConnection(sConnStr); Statement stmt = connect.createStatement(); rs = stmt.executeQuery(sql); catch(SQLException ex) System.err.println(ex.getMessage(); return rs; 1. 阅读下面的程序, 分析程序输出的结果.class Leaf int i=0;Leaf(int i)this.i=i;Leaf increament()i+;return this;void print()System.out.println(i=+i);public static void main(String args) Leaf leaf=new Leaf(100);leaf.increament().increament().print();i=1022. class StaticTest static int x=1;int y;StaticTest()y+; public static void main(String args ) StaticTest st=new StaticTest(); System.out.println(x= + x); System.out.println(st.y= + st.y); st=new StaticTest(); System.out.println(st.y= + st.y); static x+;x=2st.y=1st.y=13、interface Apublic void mA( );interface Bpublic void mB( );abstract class Cabstract public void mC ( );class D extends C implements A,Bpublic void mA( )System.out.println(“A”);public void mB( )System.out.println(“B”);public void mC( )System.out.println(“C”);class Testpublic static void main(String args)Test t =new Test ( );D d=new D( );t.method1(d);t.method2(d);t.method3(d);public void method1(A a)a.mA( ); public void method2(B b)b.mB( ); public void method3(C c)c.mC( ); ABC4、阅读以下程序,写出输出结果。 class Cruncher void crunch( int i ) System.out.print(“int”); void crunch(String s) System.out.print(“String”); public static void ma

温馨提示

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

评论

0/150

提交评论