当前位置:首页 > 面向对象程序设计技术复习题 docx
else return 3*a+x; }
publicint get() {return a;}
public static void main(String[] args) { XXK2 x=new XXK2(5); int y=x.f1(9); y+=x.get()*x.get();
System.out.println(\} }
7.
interface Shape { double area(); double girth(); }
class Rectangle implements Shape { inta,b;
public Rectangle(intaa, int bb) {a=aa; b=bb;} public double area() {return a*b;}
public double girth() {return 2*(a+b);} }
public class XXK3 {
public static void main(String[] args) { Shape x;
x=new Rectangle(6,10);
System.out.println(x.area()+\} }
8.
public class XXK4 {
public static void main(String[] args) { int []a=new int[6]; inti,s=0;
for(i=1; i 9. class ABC { String name; double price; public ABC(String na, double pr) {name=na; price=pr;} publicintcompareTo(ABC x) { if(price>x.price) return 1; if(price public class XXK5 { public static void main(String[] args) { String []s={\double []d={3.8, 2.5, 3.2, 4.3, 5.2}; ABC []ar=new ABC[s.length]; inti,k=0; for(i=0; i if(ar[i].compareTo(ar[k])>0) k=i; System.out.println(ar[k].name+\ } } 《面向对象程序设计技术》复习题答案 一、单项选择题 题号 答案 题号 答案 1 B 11 B 2 B 12 A 3 C 13 B 4 B 14 C 5 D 15 C 6 A 16 D 7 B 17 A 8 C 18 C 9 C 19 B 10 A 20 D 二、判断题(将正确答案填入下表中,正确打“√”,错误打“×”) 题号 答案 题号 答案 1 × 11 √ 2 √ 12 √ 3 × 13 √ 4 √ 14 × 5 √ 15 √ 6 √ 16 7 √ 17 8 √ 18 9 × 19 10 √ 20 × √ √ √ × 三、程序分析题 1. 输出结果:y=43 2. 输出结果:y=22 3. 运行结果:y=25 4. 输出结果:57.0, 255.0 5. 输出结果应为:max: 28min: 12 6. 输出结果:y=53 7. 输出结果:60.0, 32.0 8. 输出结果:s=30 9. 输出结果:grape 5.2
共分享92篇相关文档