欢迎来到淘文阁 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
淘文阁 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    2022年大学期末考试Java题库 .pdf

    • 资源ID:27196043       资源大小:122.36KB        全文页数:22页
    • 资源格式: PDF        下载积分:4.3金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要4.3金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    2022年大学期末考试Java题库 .pdf

    1.下面程序的运行结果是() 。public class E3 public static void main(String args) String s= 大大 ; char a=s.charAt(2),b=s.charAt(4); System.out.print(a); System.out.println(b); 2.下面程序的运行结果是() 。import java.util.*; public class LinkedListExample public static void main(String args) LinkedList linkedlist = new LinkedList(); linkedlist.add(new Integer(1); linkedlist.add(new Integer(2); linkedlist.add(new Integer(3); linkedlist.add(new Integer(4); linkedlist.add(new Integer(5); System.out.println(The original contents of the linkedlist is: ); System.out.println(linkedlist); linkedlist.add(2,hello); linkedlist.addFirst(First); linkedlist.addLast(Last); System.out.println(After adding elements ,the linkedlist is: ); System.out.println(linkedlist); 答:3.下面程序的运行结果是()。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 (aj ak) k = j; int temp = ai; ai = ak; ak = temp; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 22 页 - - - - - - - - - for (i = 0; i a.length; i+) System.out.print(ai + ); System.out.println(); 4.下面程序的运行结果是() 。public class TryCatchFinally static void Proc(int sel) try if (sel = 0) System.out.println(no Exception ); return; else if (sel = 1) int i = 0; int j = 4 / i; catch (ArithmeticException e) System.out.println(Catch ); catch (Exception e) System.out.println(Will not be executed); finally System.out.println(finally); public static void main(String args) Proc(0); Proc(1); 5.下面程序的运行结果是()。public class welcomeTest public static void main(String args) String s, s1 = ; char c; s = wELCOME; for (int i = 0; i = a & c = z) s1 = s1 + Character.toUpperCase(c); else s1 = s1 + Character.toLowerCase(c); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 22 页 - - - - - - - - - System.out.println(s1); 6.下面程序的运行结果是()。public class arrTest public static void main(String args) int i, j; int a = 2, 1, 4, 8; for (i = 0; i a.length - 1; i+) int k = i; for (j = i; j a.length; j+) if (aj ak) k = j; int temp = ai; ai = ak; ak = temp; for (i = 0; i a.length; i+) System.out.print(ai + ); System.out.println(); 7.下面程序的运行结果是(true,false)。public class StringTest public static void main(String args) String s1 = new String(abcde); String s2 = new String(abcde); boolean b1 = s1.equals(s2); boolean b2 = s1 = s2; System.out.print(b1 + , + b2); 8.下面程序运行时,若输入10,则输出结果是() 。public class test public static void main(String args) throws IOException BufferedReader buf = new BufferedReader( new InputStreamReader(System.in); while (true) String str = buf.readLine(); if (str.equals(quit) break; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3 页,共 22 页 - - - - - - - - - int x = Integer. parseInt(str); System.out.println(x * x); System.out.println(“ OK ” ); 9.下面程序的运行结果是() 。public class T public static void main(String args) Set set = new HashSet(); set.add(new Integer(10); set.add(new Integer(5); set.add(new Integer(15); set.add(new Integer(5); set.add(new Integer(10); System.out.println(size = + set.size(); Iterator it = set.iterator(); while (it.hasNext() System.out.print(it.next() + ); 10.下面程序的运行结果是() 。public class A class Dog private String name; private int age; public int step; Dog(String s, int a) name = s; age = a; step = 0; public void run(Dog fast) fast.step+; public static void main(String args) A a = new A(); Dog dog = a.new Dog(Tom, 3); dog.step = 25; dog.run(dog); System.out.println(dog.step); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 4 页,共 22 页 - - - - - - - - - 11.下面程序的运行结果是() 。class A int x=1, y=2; double add() return x+y; class B extends A int x=10, y=20; double add() return super.x + super.y; class Takecare public static void main(String args) A a = new A(); B b = new B(); System.out.println(a.add=+a.add(); System.out.println(b.add=+b.add(); 12.下面程序的运行结果是() 。for (int i = 0; i 5; i+) switch (i) default: System.out.print(defaultt); case 0: System.out.print(zerot); i+; break; case 1: System.out.print(onet); case 2: System.out.print(twot); i+; 13.下面程序的运行结果是() 。public class Example String str = new String(good); char ch = a, b, c; public void change(String str, char ch) str = test ok; ch0 = g; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 5 页,共 22 页 - - - - - - - - - public static void main(String args) Example example = new Example(); example.change(example.str, example.ch); System.out.print(example.str + and ); System.out.print(example.ch); 14.下面程序的运行结果是() 。class A public String Show(D obj) return (A and D); public String Show(A obj) return (A and A); class B extends A public String Show(B obj) return (B and B); public String Show(A obj) return (B and A); class C extends B public String Show(C obj) return (C and C); public String Show(B obj) return (C and B); class D extends B public String Show(D obj) return (D and D); public String Show(B obj) return (D and B); public class main public static void main(String args) A a1 = new A(); A a2 = new B(); B b = new B(); C c = new C(); D d = new D(); System.out.println(a1.Show(b); System.out.println(a1.Show(c); System.out.println(a1.Show(d); System.out.println(a2.Show(b); System.out.println(a2.Show(c); System.out.println(a2.Show(d); System.out.println(b.Show(b); System.out.println(b.Show(c); System.out.println(b.Show(d); 15.下面程序的运行结果是() 。public class Example extends TT 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 6 页,共 22 页 - - - - - - - - - public static void main(String args) Example t = new Example(Tom); public Example(String s) super(s); System.out.println(How do you do?); public Example() this(I am Tom); class TT public TT() System.out.println(What a pleasure!); public TT(String s) this(); System.out.println(I am + s); 16.下面程序的运行结果是() 。public class Example public static void main(String args) for (int i = 0; i 2; i+) resume: for (int j = 0; j 3; j+) for (int k = 0; k A) y=爱; z=情; else y= 我 ; z=她; System.out.println( +x+y+z); 19.下面程序的运行结果是() 。class TT public TT() System.out.println(What a peasure!); public TT(String s) this(); System.out.println(I am + s); public class Example extends TT public static void main(String args) Example example = new Example(); public Example(String s) super(s); System.out.println(How do youo do?); public Example() 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 8 页,共 22 页 - - - - - - - - - this(I am Tom); 20.下面程序的运行结果是() 。public class Example public static void main(String args) int count = 0; for (int i = 0; i 3; i+) resume: for (int j = 0; j 4; j+) for (int k = 0; k 5; k+) +count; if (i = 1 & j = 2 & k = 3) break resume; System.out.println(tcount= + count); 21.下面程序的运行结果是() 。public class A class Dog private String name; private int age; public int step; Dog(String s, int a) name = s; age = a; step = 0; public void run(Dog fast) fast.step-; public static void main(String args) A a = new A(); Dog dog = a.new Dog(Tom, 3); dog.step = 30; dog.run(dog); System.out.println(dog.step); 22.下面程序的运行结果是() 。import java.io.*; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 9 页,共 22 页 - - - - - - - - - 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(); 23.下面程序的运行结果是() 。class A public String Show(D obj) return (A and D); public String Show(A obj) return (A and A); class B extends A public String Show(B obj) return (B and B); public String Show(A obj) return (B and A); class C extends B public String Show(C obj) return (C and C); public String Show(B obj) return (C and B); class D extends B public String Show(D obj) return (D and D); public String Show(B obj) return (D and B); public class main public static void main(String args) A a1 = new A(); A a2 = new B(); B b = new B(); C c = new C(); D d = new D(); System.out.println(a1.Show(b); System.out.println(a1.Show(c); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 10 页,共 22 页 - - - - - - - - - System.out.println(a1.Show(d); System.out.println(a2.Show(b); System.out.println(a2.Show(c); System.out.println(a2.Show(d); System.out.println(b.Show(b); System.out.println(b.Show(c); System.out.println(b.Show(d); 24.下面程序的运行结果是() 。public class E public static void main(String args) long a=1,2,3,4; long b=100,200,300,400,500; b=a; System.out.println( 数组 b 的长度 :+b.length); System.out.println(b0=+b0); 25.下面程序的运行结果是() 。public class E3 public static void main(String args) String s= 西安石油大学 ; char a=s.charAt(2),b=s.charAt(4); System.out.print(a); System.out.println(b); 1.1.说出下列程序的输出结果。class Aclass void go() System.out.println(Aclass); public class Bclass extends Aclass void go() System.out.println(Bclass); public static void main(String args) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 11 页,共 22 页 - - - - - - - - - Aclass a = new Aclass(); Aclass a1 = new Bclass(); a.go(); a1.go(); 26.下面程序的运行结果是() 。import java.util.*; public class LinkedListExample public static void main(String args) LinkedList linkedlist = new LinkedList(); linkedlist.add(new Integer(1); linkedlist.add(new Integer(2); linkedlist.add(new Integer(3); linkedlist.add(new Integer(4); linkedlist.add(new Integer(5); System.out.println(The original contents of the linkedlist is: ); System.out.println(linkedlist); linkedlist.add(4,current); linkedlist.addFirst(First); linkedlist.addLast(Last); System.out.println(After adding elements ,the linkedlist is: ); System.out.println(linkedlist); 27.下面程序的运行结果是() 。class A public int f(int x) return x+1; class B extends A public int f(int x) return x*x; public class E public static void main(String args) A a=new B(); int m=a.f(10); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 12 页,共 22 页 - - - - - - - - - System.out.println(m); 28.下面程序的运行结果是() 。public class A class Dog private String name; private int age; public int step; Dog(String s, int a) name = s; age = a; step = 5; public void run(Dog fast) fast.step+; public static void main(String args) A a = new A(); Dog dog = a.new Dog(Tom, 6); dog.step = 48; dog.run(dog); System.out.println(dog.step); 29.下面程序的运行结果是() 。public class Example public static void main(String args) int count = 0; for (int i = 0; i 3; i+) resume: for (int j = 0; j 2; j+) for (int k = 0; k 4; k+) +count; if (i = 2 & j = 1 & k = 3) break resume; System.out.println(tcount= + count); 30.下面程序的运行结果是() 。public class E3 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 13 页,共 22 页 - - - - - - - - - public static void main(String args) char c=0; for(int i=1;i=4;i+) switch(i) case 1:c=b; System.out.print(c); case 2:c=e; System.out.print(c); break; case 3:c=p; System.out.print(c); default: System.out.print(!); 31.下面程序的运行结果是() 。class A public String Show(D obj) return (A and D); public String Show(A obj) return (A and A); class B extends A public String Show(B obj) return (B and B); public String Show(A obj) return (B and A); class C extends B public String Show(C obj) return (C and C); public String Show(B obj) return (C and B); class D extends B public String Show(D obj) return (D and D); public String Show(B obj) return (D and B); public class main public static void main(String args) A a1 = new A(); A a2 = new B(); B b = new B(); C c = new C(); D d = new D(); System.out.println(a1.Show(b); System.out.println(a1.Show(c); System.out.println(a1.Show(d); System.out.println(a2.Show(b); System.out.println(a2.Show(c); System.out.println(a2.Show(d); System.out.println(b.Show(b); System.out.println(b.Show(c); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 14 页,共 22 页 - - - - - - - - - System.out.println(b.Show(d); 32.下面程序的运行结果是() 。import java.util.*; public class TestList public static void main(String args) List list = new LinkedList(); print(list); list.add(C); print(list); list.add(D); print(list); for (int i = 0; i 4; i+) list.add(E); print(list); static void print(List list) System.out.println(list= + list); System.out.print(list.size= + list.size(); System.out.println(n); 33.下面程序的运行结果是() 。public class E3 public static void main(String args) String s= 西安石油大学 ; char a=s.charAt(2),b=s.charAt(4); System.out.print(a); System.out.println(b); 34.下面程序的运行结果是() 。class TT public TT() System.out.println(What a peasure!); public TT(String s) this(); System.out.println(I am + s); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 15 页,共 22 页 - - - - - - - - - public class Example extends TT public static void main(String args) Example example = new Example(); public Example(String s) super(s); System.out.println(How do you do?); public Example() this(I am Tom); 35.下面程序的运行结果是() 。public class Test static System.out.println(Hi there); public void print() System.out.println(Hello); public static void main(String args ) Test st1 = new Test(); st1.print(); Test st2 = new Test(); st2.print(); 36.下面程序的运行结果是() 。class A void operate(int c) int i; for(i=0; ic.length; i+) ci = 3*ci; class Takecare public static void main(String args) A a = new A(); int b = 1, 2, 3, 4; a.operate(b); for(int i=0; ib)?a:b); 39.如果 test.dat文件不存在 ,下面这段程序:import java.io.*; class TestIO public static void main(String args) tryFile raf=new File(test.dat,r); catch(IOException e)System.out.println(IO Exception); 运行结果: _ 。40.import java.io.*; public class C public static void main(String args) throws IOException File inputFile = new File(a.txt); File outputFile = new File(b.txt); FileReader in = new FileReader(inputFile); FileWriter out = new FileWriter(outputFile); int c; while (c = in.read() ) != -1) out.write(c); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 17 页,共 22 页 - - - - - - - - - in.close(); out.close(); 程序的功能是:_。41.阅读程序,写出程序运行结果。import java.util.*; public class LinkedListExample public static void main(String args) LinkedList linkedlist = new LinkedList(); linkedlist.add(new Integer(1); linkedlist.add(new Integer(2); linkedlist.add(new Integer(3); linkedlist.add(new Integer(4); linkedlist.add(new Integer(5); System.out.println(The original contents of the linkedlist is: ); System.out.println(linkedlist); linkedlist.add(2,hello); linkedlist.addFirst(First); linkedlist.addLast(Last); System.out.println(After adding elements ,the linkedlist is: ); System.out.println(linkedlist); linkedlist.removeLast(); linkedlist.set(1,one); System.out.println(After deleting and changing,the linkedlist is: ); System.out.println(linkedlist); System.out.println(); 42.阅读程序,写出程序运行结果。import java.util.*; public class ArrayListExample public static void main(String args) ArrayList arraylist = ne

    注意事项

    本文(2022年大学期末考试Java题库 .pdf)为本站会员(Che****ry)主动上传,淘文阁 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知淘文阁 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于淘文阁 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

    本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

    工信部备案号:黑ICP备15003705号 © 2020-2023 www.taowenge.com 淘文阁 

    收起
    展开