public static void main(String[] args) {
Person c = new Person(\, 17);
System.out.println(c.name + \ + c.age + \);
}
}
2、以下程序的输出结果为__课程号:101 课程名:ASP 学分:3___。 public class Course {
private String cNumber; private String cName; private int cUnit;
public Course(String number, String name, int unit) {
cNumber = number; cName = name; cUnit = unit;
}
public void printCourseInfo() {
System.out.println(\课程号:\ + cNumber + \课程名:\ + cName + \学分:\ +
cUnit);
}
}
class CourseTest {
public static void main(String[] args) {
Course c;
c = new Course(\, \, 3); c.printCourseInfo();
}
}
3、以下程序的输出结果为__汤姆猫体重:20.0斤___。 public class Tom {
private float weight; private static String name;
public void setWeight(float weight) {
this.weight = weight;
}
private void out() {
System.out.println(name + \体重:\ + weight + \斤\);
}
public static void main(String[] args) {
Tom.name = \汤姆猫\;
Tom cat = new Tom();
cat.setWeight(20); cat.out();
}
}
4、以下程序的输出结果__。 public class Father {
String name, address, tel;
int age;
public Father(String name, int age) {
this.name = name;
this.age = age;
}
void out() {
System.out.print(\姓名:\ + name); System.out.print(\年龄:\ + age);
}
void outOther() {
System.out.print(\家庭住址:\ + address); System.out.print(\电话:\ + tel);
}
}
class Son extends Father {
String school;
public Son(String name, int age) {
super(name, age);
}
void out() {