没有合适的资源?快使用搜索试试~ 我知道了~
首页Java复习考试题300道
Java复习考试题300道
4星 · 超过85%的资源 需积分: 9 9 下载量 18 浏览量
更新于2023-03-16
评论 3
收藏 837KB DOC 举报
Java复习考试题目300道,含有答案,亲自核对,准确率100%,对应机试十分有效的资料
资源详情
资源评论
资源推荐
第一套
单选
题目 选项
以下代码:
10. interface Jumper{public void jump();}
...
20. class Animal{}
...
30. class Dog extends Animal{
31. Tail tail;
32. }
...
40. class Beagle extends Dog implements Jumper{
41. public void jump(){}
42. }
...
50. class Cat implements Jumper{
51. public void jump(){}
52. }
以下语句哪三条是正确的?
Cat is-a Animal
Cat is-a Jumper
Dog is-a Animal
Dog is-a Jumper
Cat has-a Animal
Beagle has-a Tail
Beagle has-a Jumper
以下代码:
10. class One{
11. void foo(){}
12. }
13. class Two extends One{
14. //insert method here
15. }
在 14 行处单独插入以下哪些个方法才能让两个 Class 编
译通过?
int foo(){/* more code here */}
void foo(){/* more code here */}
public void foo(){/* more code here */}
private void foo(){/* more code here */}
protected void foo(){/* more code here */}
以下代码:
1. class Mammal{}
2.
3. class Raccoon extends Mammal
4. Mammal m = new Mammal();
Raccoon is-a Mammal.
5. }
6.
7. class BabyRaccoon extends Mammal{}
哪四条语句是正确的?
Raccoon has-a Mammal.
BabyRaccoon is-a Mammal.
BabyRaccoon is-a Raccoon.
以下代码:
1. class One{
2. public One foo(){return this;}
3. }
4. class Two extends One{
5. public One foo(){return this;}
6. }
7. class Three extends Two{
8. //insert method here
9. }
单独插入哪些方法可以成功编译三个 class
public void foo(){}
public int foo(){return 3;}
public Two foo(){return this;}
public One foo(){return this;}
public Object foo(){return this;}
以下代码:
1. class Employee{
2. String name; double baseSalary;
3. public Employee(String name, double baseSalary){
4. this.name = name;
5. this.baseSalary = baseSalary;
6. }
7. }
8. public class SalesPerson extends Employee{
9. double commission;
10. public SalesPerson(String name,
11. double baseSalary, double commission){
12. //insert code here
13. }
14. }
在 12 行处单独插入哪些代码,可以让程序编译通过?
super(name, baseSalary);
this.commission = commission;
super();
this.commission = commission;
this.commission = commission;
super();
super(name, baseSalary);
this.commission = commission;
以下代码:
1. public abstract class Shape{
2. private int x;
3. private int y;
4. public abstract void draw();
5. public void setAnchor(int x, int y){
6. this.x = x;
7. this.y = y;
8. }
9. }
正确使用 Shape 类的是?
public class Circle implements Shape{
private in radius;
}
public abstract class Circle extends Shape{
private in radius;
}
public class Circle extends Shape{
private in radius;
public void draw();
}
public abstract class Circle implements Shape{
private in radius;
public void draw();
}
public class Circle extends Shape{
private in radius;
public void draw(){/* code here */}
}
public abstract class Circle implements Shape{
private in radius;
public void draw(){/* code here */}
}
以下代码
11. public interface Status {
12. /* insert code here */ int MY_VALUE = 10;
13. }
以下哪些代码插入在 12 行处是合法的?
final
static
native
public
以下代码:
10. abstract class A{
11. abstract void a1();
12. void a2(){}
13. }
x.a2();
14. class B extends A{
15. void a1(){}
16. void a2(){}
17. }
18. class C extends B{void c1(){}}
和:
A x = new B(); C y = new C(); A z = new C();
哪些是合法的多态方法调用?
z.a2();
z.c1();
z.a1();
y.c1();
x.a1();
以下哪些代码片段是合法的读取 Console 一行文本的方
法?
String s = c.readLine();
char[] c = c.readCLine();
String s = c.readConsole();
char[] c = c.rConsole();
String s = c.readLine("%s", "name ");
char[] c = c.rLine("%s", "name ");
下列说法错误的有 在类方法中可用 this 来调用本类的类方法
在类方法中调用本类的类方法时可直接调用
在类方法中只能调用本类中的类方法
在类方法中绝对不能调用实例方法
单选
题目 选项
以下代码:
1. public class TestString1{
2. public static void main(String[] args){
3. String str = "420";
4. str += 42;
5. System.out.print(str);
6. }
7. }
输出什么?
42
420
462
42042
以下代码:
1. public class Test{
2. public static void main(String[] args){
3. int x = 5;
2
4. boolean b1 = true;
5. boolean b2 = false;
6.
7. if((x==4) && !b2)
8. System.out.print("1 ");
9. System.out.print("2 ");
10. if((b2=true) && b1)
11. System.out.print("3 ");
12. }
13. }
运行结果是什么?
3
1 2
2 3
以下代码:
22. public void go(){
23. String o = "";
24. z:
25. for(int x=0; x<3; x++){
26. for(int y=0; y<2; y++){
27. if(x == 1) break;
28. if(x==2 && y==1) break z;
29. o = o + x + y;
30. }
31. }
32. System.out.println(o);
33. }
go()方法被调用后,产生什么结果?
00
001
000120
00012021
编译错误
以下代码:
10. int x = 0;
11. int y = 10;
12. do{
13. y--;
14. ++x;
15. }while(x < 5);
16. System.out.print(x + "," + y);
运行结果是?
5,6
5,5
6,5
6,6
剩余61页未读,继续阅读
feng2009303532
- 粉丝: 2
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- RTL8188FU-Linux-v5.7.4.2-36687.20200602.tar(20765).gz
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
- SPC统计方法基础知识.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论2