JAVA语言程序设计期末考试试题及答案

2026/4/25 7:57:32

http://www.514t.com 免费提供各种资格考试真题、模拟题、练习题、精选题及答案 public Sample(long l){ length = l; } public static void main(String arg[]){ Sample s1, s2, s3; s1 = new Sample(21L); s2 = new Sample(21L); s3 = s2; long m = 21L; } } 哪个表达式返回true? [B] A. s1 == s2; B. s2 == s3; C. m == s1; D. s1.equals(m);

37. 给出下面有关java.awt.List的表达式 List l = new List(6,true);//第二个参数是false的话只能选一个 其中哪些叙述是正确的? [AC] A. 在没有其它的约束的条件下该列表将有6行可见。 B. 一行的最大字符数是6 C. 列表将允许用户多选 D. 列表只能有一项被选中

38. 给出下面的代码 class Parent { String one, two;

public Parent(String a, String b){ one = a; two = b; }

http://www.514t.com 免费提供各种资格考试真题、模拟题、练习题、精选题及答案

http://www.514t.com 免费提供各种资格考试真题、模拟题、练习题、精选题及答案 public void print(){ System.out.println(one); } }

public class Child extends Parent { public Child(String a, String b){ super(a,b); }

public void print(){ System.out.println(one + \ } public static void main(String args[]){ Parent p = new Parent(\ Parent t = new Child(\ p.print(); t.print(); } }

下面的哪些情况或输出的结果正确? [E] A. 编译时出错 B. south east C. south to north east to west D. south to north east E. south east to west

39. 类Teacher和Student都是类Person的子类 Person p; Teacher t; http://www.514t.com 免费提供各种资格考试真题、模拟题、练习题、精选题及答案

http://www.514t.com 免费提供各种资格考试真题、模拟题、练习题、精选题及答案 Student s;

若p,t和s都是非空值

if(t instanceof Person) { s = (Student)t; }

这个语句导致的结果是什么? [C] // 默认new时声明的都是本类; A. 将构造一个Student对象 B. 表达式合法 C. 编译时非法

D. 编译时合法而在运行时可能非法 40. 给出下面的代码 String s= \String t = \

char c[] = {'h','e','l','l','o'}; 下列选项里,哪些返回true? [ACD] A. s.equals(t); B. t.equals(c); C. s==t;

D. t.equals(new String(\E. t==c; 一、单选题(本大题15小题,每小题2分,共30分) 1.下列语句执行后,变量a、c的值分别是( )。 int x=182; int a,c; c=x/100; a=x;

A) 1,2 B) 2,1 C) 1.82, 2 D) 100,82 【答案】B

2.下面哪个表达式可用得到x和y的最大值( )?

http://www.514t.com 免费提供各种资格考试真题、模拟题、练习题、精选题及答案

http://www.514t.com 免费提供各种资格考试真题、模拟题、练习题、精选题及答案 A) x>y?y:x B) xy?(x+y):(x-y) D) x==y?y:x; 【答案】B

3.以下是应用程序中定义的静态方法printBinary,若在其main方法中有方法调用语句printBinary(2),则输

出的结果是 ( )。

static void printBinary(int i) { System.out.print(i + \的2进制数表示为:\\t\ for(int j = 31; j >=0; j--) if(((1 << j) & i) != 0) System.out.print(\ else

System.out.print(\ System.out.println();//换行 }

A) 00000000000000000000000000000001 B) 00000000000000000000000000000010 C) 00000000000000000000000000001111 D) 00000000000000000000000000000000 【答案】B

4. 应用程序的main方法中有以下语句,则输出的结果是 ( )。 String s1=\ double x=Double.parseDouble(s1); int y=Integer.parseInt(s2); System.out.println(x+y);

A) 12.5 B) 120.5 C) 12 D) ?12.5? 【答案】A

5. 应用程序的main方法中有以下语句,则输出的结果是 ( )。 double x=1234.1234567; DecimalFormat form1 = new DecimalFormat(\ System.out.println(\ http://www.514t.com 免费提供各种资格考试真题、模拟题、练习题、精选题及答案


JAVA语言程序设计期末考试试题及答案.doc 将本文的Word文档下载到电脑
搜索更多关于: JAVA语言程序设计期末考试试题及答案 的文档
相关推荐
相关阅读
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 10

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219