java题!
Java code:
package f;
public class TestStudent {
public static void main(String[] args) {
Student s1 = new Student();//创建父类对象
Xue x1 = new Xue();//创建子类对象;
s1.Set("张三 ", "男 ");
s1.Set(18);
s1.Set(88.8);
System.out.println(s1.Info());
x1.Set("李四 ","男 ");
x1.Set("厨师");
x1.Set(18);
x1.Set(99.9);
System.out.println(x1.Info());
Student s2 = new Xue();
s2.Set("小王","女");
s2.Set(26);
s2.Set(33.3);
}
}
class Student{ //父类
String name;
String xingbie;
int age;
double chengji;
public void Set(String name,String xingbie){
this.name = name;
this.xingbie = xingbie;
}
public void Set(int age){
this.age = age;
}
public void Set(double chengji){
this.chengji = chengji;
}
public String GetName(){
return name;
}
public String GetXingBie(){
return xingbie;
}
public int GetAge(){
return age;
}
public double GetChengJi(){
return chengji;
}
public String Info(){
return "名字:" + name + "性别:" + xingbie + "年龄:" + " " + age + " " + "成绩:" + chengji;
}
}
class Xue extends Student{ //子类 集成了父类
String zhiwu;
public void Set(String zhiwu){
this.zhiwu = zhiwu;
}
public String GetZhiWu()
相关问答:
我现在想用ssh整合来做一个论坛,但数据库方面不行,我主要不会涉及数据库,不知道发帖表,和回帖表要如何设计和区分。不知道谁有一个简单的思路,来设计这些表。谢谢了。
发帖和回帖用同一张表 。发帖 id user ......
字符流的读和写最终在底层都是通过字节流来完成的吗? 读写文本文件字符流应该就可以了吧。。
各位大哥大姐帮帮忙阿
Java流包括字节流和字符流,字节流通过IO设备以字节数据的方式读入,而字符流则是通过字节流 ......
1 public class BirthDate {
2 private int day;
3 private int month;
4 private int year;
5
6 public BirthDate (){}
7
8 public BirthDate (int d,int m,int y){
9 day = d;
......
import java.io.*;
class FileTest
{
public static void main(String [] args) throws Exception
{
File fDir=new File(File.separator);
String strFile="java源代码测试"+File.separato ......