JAVA:面向对象编程测题
上传者:李渊|上传时间:2016-09-17|密次下载
JAVA:面向对象编程测题
面向对象编程
(1)
Given the following Java code: |
class Animal { public String noise () { return "peep"} } public String noise () { return "back"; }
} public String noise () { return "move"; }
} |
A. peep |
(2)
|
Given the following Java code: |
10. |
interface A { public int getValue (); } public int getValue () { return 1; }
} // insert code here
} |
|
A. public void add(C c) { c.getValue(); } |
(3)
Add methods to the Beta class to make it compile correctly. |
class Alpha { public void bar ( int… x ) {} public void bar (int x ) {} } |
public class Beta extends Alpha { place here place here place here } |
Methods |
(4)
Given the following Java code: |
class Test1{ public Test1 foo() { return this; }
} public Test1 foo() { return this; }
} // insert method here
} |
|
(5)
Given the following Java code: |
public class Bootchy{ int bootch; String snootch;
public Bootchy() { this( "snootchy" ); System.out.print( "first " ) ; }
public Boothchy( String snootch ) { this( 420, "snootchy" ); System.out.print( "second " ) ; }
public Bootchy(int bootch, String snootch ) { this.bootch = bootch; this. snootch = snootch; System.out.print( "third " ); }
public static void main(String[] args ) { Bootchy b= new Bootchy (); System.out.print(b.snootch + " " + b.bootch ); }
} |
(6)
|
Given the following Java code: |
09. |
public class Test{ static class A { void process () throws Exception { throw new Exception () ; } }
static class B extends A { void process () { System.out.println( " B" ); } } public static void main (String[ ] args ) { A a = new B (); a.process (); }
} |
|
A. B E. Compilation fails because of an error in line 18. F. Compilation fails because of an error in line 19. |
(7)
|
Given the following Java code: |
10 |
interface Foo {} public static void main(String[] args) { Beta x = new Beta (); // insert code here }
} |
|
A. Alpha a = x; |
(8)
Given the following Java code: |
public class Person{ private String name, comment; private int age; public Person(String n, int a, String c) { name = n; age = a; comment = c; } public Boolean equals(Object o){ if (! (o instanceof Person)) return false; Person p = (Person)o; return age == p.age && name.equals(p.name); }
} |
A. return super.hashCode(); |
(9)
|
Given the following code: |
01. |
public class Person{ private String name; public Person (String name){ this.name = name; } public Boolean equals(Person p){ return p.name.equals(this.name); }
} |
|
A. The equals method does NOT properly override the object Object.equals method. B. Compilation fails because the private attribute p.name cannot be accessed in line 5. C. To work correctly with hash-based data structures, this class must also implement the hashCode method. D. When adding Person objects to java.util. Set collection, the equals method in line 4 will prevent duplicates. |
(10)
Place the Output Options in the Actual Output Sequence to indicate the output from this code: |
||||||||
class Alpha { public void foo(String... args) { System.out.print("Alpha:foo ");
} System.out.print("Alpha:bar "); }
} public void foo(String a) { System.out.print("Beta:foo ");
} System.out.print("Beta:bar ");
}
Alpha a = new Beta(); }
}
|
(11)
|
Given the following Java code: |
1. |
public interface A { public void doSomething(String thing); } |
1. |
public class AImp1 implements A { public void doSomething(String msg) {} } |
1. |
public class B { public A doit() { // more code here }
public String execute() { // more code here } } |
1. |
public class C extends B { public AImp1 doit() { // more code here }
public Object execute() { // more code here }
} |
|
B. Compilation of class C will fail because of an error int line 2. C. Compilation of class C will fail because of an error int line 6. D. Compilation of AImpl will fail because of an error in line 2. |
(12)
Given the following Java code: |
||
class A { String name = "A" ; String getName() { return name; } String greeting() { return "class A" ; }
} String name = "B" ; String greeting() { return "class B" ; }
} public static void main(String[] args) { A a = new A() ; A b = new B() ; System.out.println(a.greeting () + " has name " + a.getName () ) ; System.out.println(b.greeting () + " has name " + b.getName () ) ; }
}
|
(13)
|
Given the following Java code: |
1. |
class SuperClass { public A getA() { return new A() ; }
} public B getA() { return new B(); }
} |
|
A. Compilation will succeed if A extends B B. Compilation will succeed if B extends A C. Compilation will always fail because of an error in line 7 D. Compilation will always fail because of an error in line 8 |
(14)
|
Given the following Java code: |
1. |
class Pizza { java.util.ArrayList toppings; public final void addTopping(String topping) { toppings.add(topping); }
} public void addTopping(String topping) { System.out.println("Cannot and Uoppings"); } public static void main(String[] args) { Pizza pizza = new PepperoniPizza(); Pizza.addTopping("Mushrooms"); }
} |
|
A. Compilation fails |
(15)
|
Given the following Java code: |
10. |
interface A { void x ();
} public void x () {} public void y () {}
} public void x () {}
} |
20. |
java.util.List <A> list = new java.util.ArrayList<A> (); list.add(new B ()); list.add(new C ()); for (A a : list ) { a.x(); a.y(); }
|
|
A. The code runs with no output C. Compilation fails because of an error in line 20 D. Compilation fails because of an error in line 21 E. Compilation fails because of an error in line 23 F. Compilation fails because of an error in line 25 |
(16)
|
Given the following Java code: |
10. |
class One { void foo() {}
} // insert method here
} |
|
A. int foo(){/*more code here */} |
(17)
Which two statements are true about the hashCode method? (Choose two) |
A. The hashCode method for a given class can be used to test for object equality and object inequality for that class. (hashCode method |
(18)
Given the following Java code: |
class SomeException: |
class A: public void doSomething() {} } |
class B: public void soSomething() throws SomeException {}
} |
B. Compilation of both classes will succeed. D. Compilation of class B will fail, Compilation of class A will succeed. |
下载文档
热门试卷
- 2016年四川省内江市中考化学试卷
- 广西钦州市高新区2017届高三11月月考政治试卷
- 浙江省湖州市2016-2017学年高一上学期期中考试政治试卷
- 浙江省湖州市2016-2017学年高二上学期期中考试政治试卷
- 辽宁省铁岭市协作体2017届高三上学期第三次联考政治试卷
- 广西钦州市钦州港区2016-2017学年高二11月月考政治试卷
- 广西钦州市钦州港区2017届高三11月月考政治试卷
- 广西钦州市钦州港区2016-2017学年高一11月月考政治试卷
- 广西钦州市高新区2016-2017学年高二11月月考政治试卷
- 广西钦州市高新区2016-2017学年高一11月月考政治试卷
- 山东省滨州市三校2017届第一学期阶段测试初三英语试题
- 四川省成都七中2017届高三一诊模拟考试文科综合试卷
- 2017届普通高等学校招生全国统一考试模拟试题(附答案)
- 重庆市永川中学高2017级上期12月月考语文试题
- 江西宜春三中2017届高三第一学期第二次月考文科综合试题
- 内蒙古赤峰二中2017届高三上学期第三次月考英语试题
- 2017年六年级(上)数学期末考试卷
- 2017人教版小学英语三年级上期末笔试题
- 江苏省常州西藏民族中学2016-2017学年九年级思想品德第一学期第二次阶段测试试卷
- 重庆市九龙坡区七校2016-2017学年上期八年级素质测查(二)语文学科试题卷
- 江苏省无锡市钱桥中学2016年12月八年级语文阶段性测试卷
- 江苏省无锡市钱桥中学2016-2017学年七年级英语12月阶段检测试卷
- 山东省邹城市第八中学2016-2017学年八年级12月物理第4章试题(无答案)
- 【人教版】河北省2015-2016学年度九年级上期末语文试题卷(附答案)
- 四川省简阳市阳安中学2016年12月高二月考英语试卷
- 四川省成都龙泉中学高三上学期2016年12月月考试题文科综合能力测试
- 安徽省滁州中学2016—2017学年度第一学期12月月考高三英语试卷
- 山东省武城县第二中学2016.12高一年级上学期第二次月考历史试题(必修一第四、五单元)
- 福建省四地六校联考2016-2017学年上学期第三次月考高三化学试卷
- 甘肃省武威第二十三中学2016—2017学年度八年级第一学期12月月考生物试卷
网友关注
- lol英雄联盟S6新装备介绍,S6装备改动
- 简析新医改下医院人力资源配置的优化措施
- 十五种发达肌肉的训练方法
- 2015年6月国内外时事政治
- 行政管理毕业论文题目参考
- 各地2015年公务员考试职位表
- 关于气沉丹田的理解
- 蛙泳的换气技巧
- 养胃必吃这6种食物
- 浅析医院内部控制存在的问题及完善措施
- 十四个很准的心理暗示
- 和女孩聊天话题如何开展?
- 论高校教育管理执行力缺失的成因及对策
- 建设银行校园招聘面试时间
- 交通银行校园招聘面试公告
- 论高校教育管理执行力缺失的成因及对策
- 工程项目管理学习心得体会
- 鞍钢1780mm大型宽带钢冷轧生产线工艺装备技术
- 2015年微信涨粉互动游戏测评
- 训练腿部肌肉的最好方法是什么?
- 金庸与古龙的巅峰对决
- 硕士毕业论文写作方法和技巧
- 工商管理毕业论文范文
- 熬夜族四大养胃食疗方6大食物
- 学位论文和学术论文写作的格式标准
- 干莲子怎么吃?5种干莲子的做法
- 探究新时期公路管理单位人力资源激励机制
- 电力工程施工工程中的项目成本管理分析
- 家装风格和色彩搭配技巧
- 经济管理毕业论文范文
网友关注视频
- 沪教版八年级下册数学练习册20.4(2)一次函数的应用2P8
- 苏科版八年级数学下册7.2《统计图的选用》
- 8.练习八_第一课时(特等奖)(苏教版三年级上册)_T142692
- 沪教版牛津小学英语(深圳用) 四年级下册 Unit 7
- 冀教版英语三年级下册第二课
- 七年级英语下册 上海牛津版 Unit5
- 沪教版八年级下册数学练习册21.3(2)分式方程P15
- 第8课 对称剪纸_第一课时(二等奖)(沪书画版二年级上册)_T3784187
- 【部编】人教版语文七年级下册《泊秦淮》优质课教学视频+PPT课件+教案,湖北省
- 二年级下册数学第二课
- 冀教版小学数学二年级下册第二周第2课时《我们的测量》宝丰街小学庞志荣.mp4
- 【部编】人教版语文七年级下册《老山界》优质课教学视频+PPT课件+教案,安徽省
- 北师大版八年级物理下册 第六章 常见的光学仪器(二)探究凸透镜成像的规律
- 【部编】人教版语文七年级下册《泊秦淮》优质课教学视频+PPT课件+教案,天津市
- 【部编】人教版语文七年级下册《老山界》优质课教学视频+PPT课件+教案,安徽省
- 3月2日小学二年级数学下册(数一数)
- 第五单元 民族艺术的瑰宝_16. 形形色色的民族乐器_第一课时(岭南版六年级上册)_T3751175
- 第五单元 民族艺术的瑰宝_16. 形形色色的民族乐器_第一课时(岭南版六年级上册)_T1406126
- 青岛版教材五年级下册第四单元(走进军营——方向与位置)用数对确定位置(一等奖)
- 外研版英语七年级下册module3 unit2第一课时
- 第五单元 民族艺术的瑰宝_15. 多姿多彩的民族服饰_第二课时(市一等奖)(岭南版六年级上册)_T129830
- 沪教版牛津小学英语(深圳用)五年级下册 Unit 1
- 沪教版牛津小学英语(深圳用) 五年级下册 Unit 10
- 外研版英语七年级下册module3 unit1第二课时
- 河南省名校课堂七年级下册英语第一课(2020年2月10日)
- 19 爱护鸟类_第一课时(二等奖)(桂美版二年级下册)_T502436
- 冀教版小学数学二年级下册1
- 沪教版八年级下册数学练习册21.4(1)无理方程P18
- 二次函数求实际问题中的最值_第一课时(特等奖)(冀教版九年级下册)_T144339
- 北师大版数学 四年级下册 第三单元 第二节 小数点搬家
精品推荐
- 2016-2017学年高一语文人教版必修一+模块学业水平检测试题(含答案)
- 广西钦州市高新区2017届高三11月月考政治试卷
- 浙江省湖州市2016-2017学年高一上学期期中考试政治试卷
- 浙江省湖州市2016-2017学年高二上学期期中考试政治试卷
- 辽宁省铁岭市协作体2017届高三上学期第三次联考政治试卷
- 广西钦州市钦州港区2016-2017学年高二11月月考政治试卷
- 广西钦州市钦州港区2017届高三11月月考政治试卷
- 广西钦州市钦州港区2016-2017学年高一11月月考政治试卷
- 广西钦州市高新区2016-2017学年高二11月月考政治试卷
- 广西钦州市高新区2016-2017学年高一11月月考政治试卷
分类导航
- 互联网
- 电脑基础知识
- 计算机软件及应用
- 计算机硬件及网络
- 计算机应用/办公自动化
- .NET
- 数据结构与算法
- Java
- SEO
- C/C++资料
- linux/Unix相关
- 手机开发
- UML理论/建模
- 并行计算/云计算
- 嵌入式开发
- windows相关
- 软件工程
- 管理信息系统
- 开发文档
- 图形图像
- 网络与通信
- 网络信息安全
- 电子支付
- Labview
- matlab
- 网络资源
- Python
- Delphi/Perl
- 评测
- Flash/Flex
- CSS/Script
- 计算机原理
- PHP资料
- 数据挖掘与模式识别
- Web服务
- 数据库
- Visual Basic
- 电子商务
- 服务器
- 搜索引擎优化
- 存储
- 架构
- 行业软件
- 人工智能
- 计算机辅助设计
- 多媒体
- 软件测试
- 计算机硬件与维护
- 网站策划/UE
- 网页设计/UI
- 网吧管理