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月月考生物试卷
网友关注
- 创意简历模板五百丁JM0194A
- 2011年小学教育基础知识考试说明
- HD2010操作说明
- 汽车技术等级评定检测收费标准
- 创意简历模板五百丁JM0205A
- 创意简历模板五百丁JM0193A
- 妇幼党建工作信息 第三期
- 山东畜牧兽医职业学院2015年单独招生简章
- 创意简历模板五百丁JM0182
- 创意简历模板五百丁JM0001Y
- 创意简历模板五百丁JM0198A
- 创意简历模板五百丁JM0209A
- [优质文档]大师长教师求职简历模型大全[1]
- 化工贸易求职简历模板
- erp应用实施工程师求职简历模板
- 武汉美术网为大家提供2013年全国各院校艺术类专业招生简章
- 创意简历模板五百丁JM0200A
- 建筑企业管理规章制度,建筑施工现场综合考评办法及质量验收标准规范,建筑企业强制性条文实施手册
- 业务文员求职简历模板
- 创意简历模板五百丁JM0224A
- 应用文书基础知识
- 创意简历模板五百丁JM0204A
- 创意简历模板五百丁JM0178
- 全面包装个人求职简历
- 创意简历模板五百丁JM0176
- 巧用邮箱追踪求职简历
- 一级windows无纸化考试说明
- 创意简历模板五百丁JM0202A
- 创意简历模板五百丁JM0185A
- 创意简历模板五百丁JM0199A
网友关注视频
- 人教版历史八年级下册第一课《中华人民共和国成立》
- 三年级英语单词记忆下册(沪教版)第一二单元复习
- 【部编】人教版语文七年级下册《逢入京使》优质课教学视频+PPT课件+教案,辽宁省
- 精品·同步课程 历史 八年级 上册 第15集 近代科学技术与思想文化
- 沪教版牛津小学英语(深圳用)五年级下册 Unit 1
- 沪教版八年级下册数学练习册21.3(3)分式方程P17
- 二年级下册数学第一课
- 北师大版八年级物理下册 第六章 常见的光学仪器(二)探究凸透镜成像的规律
- 北师大版数学四年级下册第三单元第四节街心广场
- 3月2日小学二年级数学下册(数一数)
- 沪教版牛津小学英语(深圳用) 六年级下册 Unit 7
- 3.2 数学二年级下册第二单元 表内除法(一)整理和复习 李菲菲
- 北师大版数学 四年级下册 第三单元 第二节 小数点搬家
- 小学英语单词
- 冀教版小学数学二年级下册第二周第2课时《我们的测量》宝丰街小学庞志荣.mp4
- 冀教版小学英语四年级下册Lesson2授课视频
- 【部编】人教版语文七年级下册《过松源晨炊漆公店(其五)》优质课教学视频+PPT课件+教案,辽宁省
- 第8课 对称剪纸_第一课时(二等奖)(沪书画版二年级上册)_T3784187
- 六年级英语下册上海牛津版教材讲解 U1单词
- 苏科版八年级数学下册7.2《统计图的选用》
- 沪教版牛津小学英语(深圳用) 四年级下册 Unit 3
- 外研版英语三起5年级下册(14版)Module3 Unit2
- 第五单元 民族艺术的瑰宝_15. 多姿多彩的民族服饰_第二课时(市一等奖)(岭南版六年级上册)_T129830
- 第12章 圆锥曲线_12.7 抛物线的标准方程_第一课时(特等奖)(沪教版高二下册)_T274713
- 冀教版小学数学二年级下册第二单元《有余数除法的竖式计算》
- 冀教版英语四年级下册第二课
- 【部编】人教版语文七年级下册《老山界》优质课教学视频+PPT课件+教案,安徽省
- 沪教版牛津小学英语(深圳用) 四年级下册 Unit 2
- 【部编】人教版语文七年级下册《泊秦淮》优质课教学视频+PPT课件+教案,广东省
- 外研版英语七年级下册module3 unit1第二课时
精品推荐
- 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
- 网吧管理