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月月考生物试卷
网友关注
- 大工15年春《行政法与行政诉讼法》在线作业一100分答案
- 2015三支一扶考试行测备考:选词填空近义词辨析
- 2015江西农村信用社招聘考试行测哲学常识
- 山东冲刺数量资料讲义
- 2013年上半年四川公务员考试《行测》模拟试题及答案详解2
- 2013年《公务员法及配套法律法规》考试试题(一)
- 2015江西银行春季招聘行测追及问题
- 试题
- 模拟试卷
- 2015江西农村信用社考试行测:“多次相遇”解题技巧
- 15春天大《房屋建筑学(工业厂房)》在线作业一满分答案
- 2015三支一扶考试行测:图形推理速解技巧之五大思考思路
- 2015江西公务员面试冲刺模拟练习题(4)
- 2015江西公务员面试备考指南
- 2015山西三支一扶综合备考:公共基础知识之常识问题-化学
- 注册会计师《经济法》知识点:保证方式
- 2013年4月13日辽宁省联考行测真题
- 南昌2015会计从业资格证考前培训学校首选卓越昂立会计会计从业资格考试会计基础第三章第二节复式记账三
- 2015年注册会计师《经济法》知识点:代位权
- 2015江西银行校园招聘每日一练(5.12)
- 2015江西银行招聘行测常识判断法律要点
- 【名师讲堂】干锅腊牛舌
- 注册会计师《经济法》知识点:合同担保的基本理论
- 大工15年春《市场营销》在线作业三100分答案
- 15春天大《房屋建筑学(工业厂房)》在线作业二满分答案
- 大工15年春《行政法与行政诉讼法》在线作业二100分答案
- NLP创始人班德勒催眠讲义
- 第五章 会计职业道德
- 2015江西三支一扶考试行测提升数学能力的秘诀:练习一题多解
- MBA是如何保过的
网友关注视频
- 苏科版数学八年级下册9.2《中心对称和中心对称图形》
- 8 随形想象_第一课时(二等奖)(沪教版二年级上册)_T3786594
- 沪教版牛津小学英语(深圳用) 五年级下册 Unit 12
- 人教版历史八年级下册第一课《中华人民共和国成立》
- 冀教版小学数学二年级下册第二周第2课时《我们的测量》宝丰街小学庞志荣.mp4
- 8.练习八_第一课时(特等奖)(苏教版三年级上册)_T142692
- 沪教版牛津小学英语(深圳用) 四年级下册 Unit 7
- 精品·同步课程 历史 八年级 上册 第15集 近代科学技术与思想文化
- 外研版英语七年级下册module3 unit2第一课时
- 第12章 圆锥曲线_12.7 抛物线的标准方程_第一课时(特等奖)(沪教版高二下册)_T274713
- 七年级英语下册 上海牛津版 Unit9
- 外研版英语三起5年级下册(14版)Module3 Unit2
- 沪教版牛津小学英语(深圳用) 六年级下册 Unit 7
- 北师大版八年级物理下册 第六章 常见的光学仪器(二)探究凸透镜成像的规律
- 北师大版数学 四年级下册 第三单元 第二节 小数点搬家
- 北师大版小学数学四年级下册第15课小数乘小数一
- 第4章 幂函数、指数函数和对数函数(下)_六 指数方程和对数方程_4.7 简单的指数方程_第一课时(沪教版高一下册)_T1566237
- 外研版英语三起6年级下册(14版)Module3 Unit2
- 3.2 数学二年级下册第二单元 表内除法(一)整理和复习 李菲菲
- 沪教版牛津小学英语(深圳用) 四年级下册 Unit 12
- 19 爱护鸟类_第一课时(二等奖)(桂美版二年级下册)_T502436
- 【部编】人教版语文七年级下册《老山界》优质课教学视频+PPT课件+教案,安徽省
- 每天日常投篮练习第一天森哥打卡上脚 Nike PG 2 如何调整运球跳投手感?
- 30.3 由不共线三点的坐标确定二次函数_第一课时(市一等奖)(冀教版九年级下册)_T144342
- 化学九年级下册全册同步 人教版 第18集 常见的酸和碱(二)
- 冀教版小学数学二年级下册第二单元《余数和除数的关系》
- 第19课 我喜欢的鸟_第一课时(二等奖)(人美杨永善版二年级下册)_T644386
- 外研版英语七年级下册module3 unit2第二课时
- 沪教版八年级下次数学练习册21.4(2)无理方程P19
- 苏科版数学七年级下册7.2《探索平行线的性质》
精品推荐
- 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
- 网吧管理