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月月考生物试卷
网友关注
- 现代俄语感叹句问题的研究
- [优质文档]第八章(2) 足本措辞简介36763
- [优质文档]进口汽车维修技巧缩略英语词典
- 2011年5月商贸俄语等级证书真题 中级
- C sharp 23种设计框架 第1章 单件框架(Single Pattern
- [最新]英语词典
- [最新]英语姓名词典
- 英语单词卡
- 商务词典[精彩]
- [精品]家具英语词汇大全
- C sharp 的23种设计框架
- 学好词汇的前提--科学选择与应用词典
- 法语电影推荐十
- WPF:从WPF Diagram Designer Part 2学习面板、缩略图、框线选择和工具箱
- NET开发实例03.六大布局收尾及经典布局属性汇总
- 俄语翻译中文简历写作 (最新)
- 极限编程在网上书店管理系统中的应用研究
- [宝典]俄语进门(1)
- Presentation Framework
- 一步一步循序渐进学习TP1-9
- [宝典]商务词典
- 建筑专业英语词汇(s)
- 50个记忆口诀让你轻松记单词[新版]
- [整理版]大学俄语四级模拟试题4
- WPF 基本图形的使用 (3)图形的操作
- [WPF]_使用Grid与GridSplitter排版布局
- 数学词典[精品]
- 化学及化工专业词汇英语翻译
- C sharp 深入浅出新接触
- 英语词汇
网友关注视频
- 沪教版牛津小学英语(深圳用) 五年级下册 Unit 10
- 8.练习八_第一课时(特等奖)(苏教版三年级上册)_T142692
- 化学九年级下册全册同步 人教版 第22集 酸和碱的中和反应(一)
- 二年级下册数学第二课
- 30.3 由不共线三点的坐标确定二次函数_第一课时(市一等奖)(冀教版九年级下册)_T144342
- 冀教版英语三年级下册第二课
- 七年级英语下册 上海牛津版 Unit5
- 二年级下册数学第一课
- 8.对剪花样_第一课时(二等奖)(冀美版二年级上册)_T515402
- 北师大版八年级物理下册 第六章 常见的光学仪器(二)探究凸透镜成像的规律
- 外研版英语三起5年级下册(14版)Module3 Unit1
- 【部编】人教版语文七年级下册《泊秦淮》优质课教学视频+PPT课件+教案,辽宁省
- 第12章 圆锥曲线_12.7 抛物线的标准方程_第一课时(特等奖)(沪教版高二下册)_T274713
- 北师大版数学四年级下册3.4包装
- 第五单元 民族艺术的瑰宝_16. 形形色色的民族乐器_第一课时(岭南版六年级上册)_T1406126
- 沪教版牛津小学英语(深圳用) 五年级下册 Unit 12
- 【部编】人教版语文七年级下册《老山界》优质课教学视频+PPT课件+教案,安徽省
- 冀教版小学英语五年级下册lesson2教学视频(2)
- 8 随形想象_第一课时(二等奖)(沪教版二年级上册)_T3786594
- 【部编】人教版语文七年级下册《逢入京使》优质课教学视频+PPT课件+教案,安徽省
- 【获奖】科粤版初三九年级化学下册第七章7.3浓稀的表示
- 19 爱护鸟类_第一课时(二等奖)(桂美版二年级下册)_T3763925
- 三年级英语单词记忆下册(沪教版)第一二单元复习
- 沪教版牛津小学英语(深圳用) 四年级下册 Unit 4
- 冀教版小学数学二年级下册1
- 沪教版八年级下册数学练习册20.4(2)一次函数的应用2P8
- 七年级下册外研版英语M8U2reading
- 冀教版英语五年级下册第二课课程解读
- 《小学数学二年级下册》第二单元测试题讲解
- 沪教版牛津小学英语(深圳用) 四年级下册 Unit 3
精品推荐
- 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
- 网吧管理