77范文网 - 专业文章范例文档资料分享平台

一有关java的第四次题(5)

来源:网络收集 时间:2018-12-04 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

}

public Mytime getTime() { return time; }

public void setTime(Mytime time) { this.time = time; }

public Mydate getDate() { return date; }

public void setDate(Mydate date) {

this.date = date; }

public String toString() { return date+\的\+time; }

}

package timedate;

public class Text {

public static void main(String[] args) { Mytime a = new Mytime(22, 12, 35); Mydate b=new Mydate(2002,7,30);

FullTime c=new FullTime(b,a);

System.out.println(c.toString());

} }

5 package Student;

public class student { int num;

String name; double score;

student(int num, String name, double score) { this.num = num; }

public void A() {

this.name = name; this.score = score;

System.out.println(\学号:\ + num + \名字:\ + name + \成绩:

\ + score); } }

package Student;

public class text { }

public static void main(String[] args) { student a[]=new student[3]; a[0]=new student(01,\,94); a[1]=new student(02,\,98); a[2]=new student(03,\,99);

for (int j = 0; j < a.length; j++) {

for (int i = 0; i < a.length - 1; i++) {

if (a[i].score < a[i + 1].score) { student b = a[i]; a[i] = a[i + 1]; a[i + 1] = b; }

} }

for(int i=0;i

二 选择题

1. B 2.B 3.B 4.CD 5.B 6.B 7.B 8.A 9.BD 10.C 程序分析题:

1 this super this super 2 public static void add(final int x2) {

x2++;

}

有final修饰的属性不能被第二次赋值。

3 用final修饰的类是不能被继承的类。 4 用final修饰的方法不能被重写。 三 编程题 1 package person;

public class Person { String name; int age;

double height;

Person(String name,int age,double height){ this.name=name; this.age=age;

this.height=height; }

public void sayHello(){

System.out.println(name+\); } }

package person;

public class Student extends Person { double score;

Student(String name, int age, double height, double score) { super(name, age, height); this.score = score; }

public void study() {

System.out.println(name + \的成绩是\ + score); }

public void sayHello() { super.sayHello(); }

}

package person;

public class Text {

public static void main(String[] args) {

Person a=new Person(\,23,1.53); a.sayHello();

Student b=new Student(\,23,1.53,90); b.sayHello(); b.study();

} }

2 package tuxing;

public abstract class Shape { double area; double per; String color; Shape(){}

Shape(String c){

color=c; }

public abstract void getArea(); public abstract void getPer(); public abstract void showAll(); public void getcolor(){

System.out.println(color); } }

public class Rectangle extends Shape{ double width;

double height; Rectangle(){}

Rectangle(double w,double h,String color){

super(color); width=w;

height=h; }

public void getArea(){

System.out.println(\矩形的面积:\+width*height); }

public void getPer(){

System.out.println(\矩形的周长:\+2*(width+height)); }

public void showAll(){

this.getArea(); this.getPer();

System.out.println(\矩形的颜色:\+color);

}

}

public class Circle extends Shape{ double radius;

Circle(){}

Circle(double r,String color){ }

public void getArea(){

System.out.println(\圆的面积:\+Math.PI*radius*radius); }

public void getPer(){

System.out.println(\圆的周长:\+2*Math.PI*radius); }

public void showAll(){ this.getArea(); this.getPer();

System.out.println(\圆的颜色:\+color); }

super(color); radius=r;

}

public class PolyDemo {

public static void main(String[] args) { }

Rectangle a=new Rectangle(2,3,\); a.showAll();

Circle b=new Circle(3,\); b.showAll(); }

3 package qiche;

public class Vehicle { private String brand; private String color; private double speed=0;

Vehicle(String b,String c,double s){ brand=b; color=c; speed=s; }

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库一有关java的第四次题(5)在线全文阅读。

一有关java的第四次题(5).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/zonghe/337162.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: