《Java 语言程序设计》阶段测试题
更新时间:2023-11-13 01:01:01 阅读量: 教育文库 文档下载
- java线下培训推荐度:
- 相关推荐
《Java 语言高级程序设计一》阶段测试题(一)
题号 答案 题号 答案 题号 答案 1 A 10 ACD 2 E 11 E 3 A 12 CD 4 AE 13 B 5 E 14 D 6 D 15 B 7 A 16 C 8 D 17 C 9 AE 18 D (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) 11 F T T F T T F T F T F
一、选择题(共18题,每题5分,共90分)
试题1:当你编译运行下列程序代码,会得到什么结果? public class Sample {
public static void main(String args[]) {
int i = 4;
float f = 4.3; double d = 1.8; int c = 0;
if (i == f) c++;
if (((int) (f + d)) == ((int) f + (int) d)) c += 2; System.out.println(c); } }
a) 这段代码不能通过编译。 b) 0输出在屏幕中。 c) 1输出在屏幕中。 d) 2输出在屏幕中。 e) 3输出在屏幕中。
试题2:当你编译运行下列程序代码,会得到什么结果? class Mystery {
String s;
public static void main(String[] args) {
Mystery m = new Mystery(); m.go(); }
void Mystery() {
s = \ }
1
void go() {
System.out.println(s); } }
a) 这段代码不能通过编译。
b) 这段代码能通过编译,但是运行时会有异常。 c) 这段代码能运行,但不输出任何结果。
d) 这段代码能运行并且输出constructor在屏幕中。 e) 这段代码能运行并且输出null在屏幕中。
试题3:当你编译运行下列程序代码,会得到什么结果? private class Base{ Base(){ int i = 100;
System.out.println(i); } }
public class Pri extends Base{ static int i = 200;
public static void main(String argv[]){ Pri p = new Pri();
System.out.println(i); } }
a) 这段代码不能通过编译。 b) 输出200。
c) 输出100和200。 d) 输出100。
试题4:考虑以下代码, 在注释的位置,插入哪条方法声明不会引起编译错误?
public class Qdd1f {
public long sum(long a, long b) { return a + b; } // 在这里插入新的方法 }
a) public int sum(int a, int b) { return a + b; } b) public int sum(long a, long b) { return 0; } c) abstract int sum();
2
d) private long sum(long a, long b) { return a + b; } e) public long sum(long a, int b) { return a + b;} 试题5:当你编译运行下列程序代码,会得到什么结果? class Base {
int i;
Base() { add(1); }
void add(int v) { i += v; }
void print() { System.out.println(i); } }
class Extension extends Base {
Extension() { add(2); } void add(int v) { i += v*2; } }
public class Qd073 {
public static void main(String args[]) {
bogo(new Extension()); }
static void bogo(Base b) {
b.add(8); b.print(); } }
a) 9 b) 18 c) 20 d) 21 e) 22 试题6当你编译运行下列程序代码,会得到什么结果? class Base{
void test() { System.out.println(\ } }
public class Child extends Base {
void test() { System.out.println(\ } static public void main(String[] a) {
Base baseObj = new Child(); baseObj.test(); } }
a) Child.test()
Base.test()
3
b) Base.test()
Child.test() c) Base.test() d) Child.test()
e) Runtime error. java.lang.ClassCastException 试题7当你编译运行下列程序代码,会得到什么结果? 01: class Base 02:{
03: final int MAX_SIZE; 04: Base(){
05: MAX_SIZE = 10;//初始化一个值 06: } 07:
08: void test() { 09: MAX_SIZE++;
10: System.out.println(\11: } 12: 13:}
a) 在第9行产生编译错误:不能改变常量MAX_SIZE的值 b) 在第3行产生编译错误:不能定义空常量MAX_SIZE c) 在第5行产生编译错误:不能为空常量MAX_SIZE赋值 d) 编译通过
试题8考虑下列代码,将产生什么结果?///值得传递 public class Test {
public static void main(String args[]) { String a = new String(\String b = new String(\Test.swap(a,b);
System.out.println(\}
static void swap (String a, String b) {
a=a+\b=a; } }
4
a. a is One more
b is Two b. a is One
b is One
c. a is One more
b is One more d. a is One
b is Two
e. a is One more
b is Two more
试题9下列哪行语句不会产生编译警告和错误? a) float f=0; b) char c=\ c) byte b=157; d) boolean f=null; e) int i=10;
试题10 下列哪一个是合法的Java标识符? a) _1_ b) int c) byte1 d) $Value e) goto f) 3Value
试题11当你编译运行下列程序代码,会得到什么结果? 1:public class Base{ 2:
3: private void test() { 4:
5: String aStr = \
6: String bStr = new String();
7: String cStr = new String(\8: String dStr = aStr;
9: System.out.println(aStr + \10: } 11:
12: static public void main(String[] a) {
5
正在阅读:
《Java 语言程序设计》阶段测试题11-13
2014届高三化学一轮复习教学案3.1钠及其化合物04-02
企业风险评估报告书12-30
幼儿园中班家长工作计划下学期精选03-27
关于读书汇报的主持词四年级的05-20
建设工程质量安全监督管理工作要点04-12
中国海军还应该走多远05-12
迈世通普及版胰岛素泵与注射笔的区别10-25
2013上半年婴幼儿配方羊奶粉质量排行榜12-26
炼钢课程设计12-17
- exercise2
- 铅锌矿详查地质设计 - 图文
- 厨余垃圾、餐厨垃圾堆肥系统设计方案
- 陈明珠开题报告
- 化工原理精选例题
- 政府形象宣传册营销案例
- 小学一至三年级语文阅读专项练习题
- 2014.民诉 期末考试 复习题
- 巅峰智业 - 做好顶层设计对建设城市的重要意义
- (三起)冀教版三年级英语上册Unit4 Lesson24练习题及答案
- 2017年实心轮胎现状及发展趋势分析(目录)
- 基于GIS的农用地定级技术研究定稿
- 2017-2022年中国医疗保健市场调查与市场前景预测报告(目录) - 图文
- 作业
- OFDM技术仿真(MATLAB代码) - 图文
- Android工程师笔试题及答案
- 生命密码联合密码
- 空间地上权若干法律问题探究
- 江苏学业水平测试《机械基础》模拟试题
- 选课走班实施方案
- 测试题
- 程序设计
- 阶段
- 语言
- Java
- “弯腰行动、净化校园”活动方案
- 《农村小学乡土校本课程的开发与实施研究》工作报告
- 行政诉讼答辩状
- 红梅树木 - 图文
- 操作系统期末测试题2套带答案
- 2017年公需科目大数据时代的互联网信息安全考试答案(5)
- 完善公共文化服务体系规范农村文化广场建设工作方案
- 建筑物理习题及答案1
- 气体动理论
- 2016年里约奥运会羽毛球男双决赛技术运用对比分析
- 论新形势下和谐警民关系的构建
- 1操作系统题
- 聚类算法总结
- 中国航天科学技术的主要成就与发展趋势
- 农村幼儿园音乐教育浅议
- 2015年春中国石油大学(北京)石油工程概论 第一阶段在线作业
- 中国百合鲜切花行业市场前景分析预测年度报告(目录) - 图文
- 法院认定合同未生效与无效有和区别
- 发展中国特色社会主义文化教案
- 钢筋施工方案