本帖最后由 lucy198921 于 2013-3-31 18:53 编辑
-
- class Car {
- int carNumber;
- Car(){}
- Car(int no){
- this.carNumber=no;
- }
- void setNumber(int carNum) {
- carNumber = carNum;
- }
- void showNumber() {
- System.out.println(“My car No. is :” + carNumber);
- }
- }
- public class CarDemo {
- public static void main(String args[]){
- Car demoCar1= new Car();
- demoCar1.setNumber(168168);
- demoCar1.showNumber();
- }
- }
复制代码列举出这个类里面的成员变量和成员方法以及构造方法,main方法后产生了多少个对象?
|