Current location - Education and Training Encyclopedia - Education and training - Guilin java training
Guilin java training
Please don't make trouble on the first floor. First, your class must be lowercase. Secondly, the class name cannot be followed by (). There are too many mistakes, so I won't give examples.

The following is the landlord's answer.

Topic 2:

Category point {}

Class Circle extends Point{// inherits the Point class.

public int x; //X coordinate

public int y; //Y coordinate

Public int r;; //Radius

The public double getArea(int r){// method used to find the area.

Returns 3.14 * r * r;

}

Public circle (int x, int y, int r){// constructor.

this.x = x

this.y = y

this.r = r

}

Public Circle() {// constructor

}

}

Common class test {//main function

Public static void main(String[] args) {

Circle circle=new Circle( 1,2,3); //Instantiate the object of the Circle class

System.out.println ("coordinate is" +circle.x+ ","+circle.y+"\t radius is "+circle.r"); //output its center coordinate radius.

system . out . println(" area is "+circle . get area(circle . r)); //output area

}

}

Theme 3:

Class College {//Class College

Public void method () {//

System.out.println ("Guilin University of Aeronautics and Astronautics");

}

}

Public class schools {//class schools

Public static void main(String[] args) {

College c 1 = new college ();

for(int I = 0; I<3; i++) {

c 1 . xianshi();

}

}

}