




已阅读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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 诊室患者安全管理制度
- 诊所新风设备管理制度
- 试件标准养护管理制度
- 财务签字审批管理制度
- 财政扶贫项目管理制度
- 货品安全配送管理制度
- 货物运输变更管理制度
- 货车司机仓库管理制度
- 物资采购沟通协议书范本
- 护理心理学案例分析 课件
- 天津公务员考试真题2024
- 重点人口管理工作规定
- 肾挫伤患者护理查房
- 山东省烟台市、龙口市2025届中考生物考试模拟冲刺卷含解析
- 2024-2025学年安徽省芜湖无为市六年级下学期小升初招生数学试卷含解析
- 东方经(已经排好版)
- DB14-T 3225-2025 煤矸石生态回填环境保护技术规范
- 福建省厦门市2022-2023学年高二下学期质量检测生物试题(解析版)
- 管道直饮水项目初步方案
- 2025年燃气轮机值班员职业技能知识考试题库
- 劳务外包服务投标方案(技术标)
评论
0/150
提交评论