ldcf.net
当前位置:首页 >> 一JAVA题求解 >>

一JAVA题求解

第1个文件:Person.java public class Person{ private String name; private String sex; private String age; private String country; public void eat(){ System.out.println("Person吃饭"); } public void sleep(){ System.out.println("Pe...

class Animal { Animal type; void sound() { //detailed method } } class Dog extends Animal { void sound() { //detailed method } } class Cat extends Animal { void sound() { //detailed method } } public class AnimalDemo { public s...

import java.util.LinkedList; import java.util.List; public class Student { private int id; // 学号 private String name; // 姓名 private int age; // 年龄 private int sex; // 性别 0,女;1,男 List students = new LinkedList(); /*...

完整代码如下,复制到eclipse中运行: public class StuExam {private String snum;// 学号private String cnum;// 班号private String name;// 姓名private char sex;// 性别private int age;// 年龄// get/set方法用来获取/设置学生实例对象的...

完整代码如下,复制到eclipse中运行: public class Cube {private double l1;// 长private double w1;// 宽private double h1;// 高// get/set方法用来获取/设置长方体实例对象的信息public double getL1() {return l1;}public void setL1(doub...

程序输出是: id: 2 animal: cat 分析: main()中只有一行代码,就是new Cat();此时会追索Cat的父类,然后运行父类的构造函数,依次向下,最后运行Cat的构造函数。 Cat的父类是Animal类,而Animal的无参构造函数有两行代码: this(2); //此处运...

public class Account{ private int id; private String name; private String personId; private double balance; public void deposit(double mon){ balance += mon; } public void withdraw(double mon){ if(balance > 0 && balance > mon) b...

int[] s={-1,5,-3,3,2,-8,6,5,-9,9,7}; //定义一个任意长度的原数组 int len=s.length; //获得原数组长度 int[] s1=new int[len]; //定义一个用于保存倒叙后的新数组,长度为原数组长度 for(int i=0;i

public class Student {private String id;private String name;public Student(String id, String name) {super();this.id = id;this.name = name;}public String getId() {return id;}public String getName() {return name;}public void disp...

网站首页 | 网站地图
All rights reserved Powered by www.ldcf.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com