- Yes, by using constructor method
- The name of it will be same as class name
class car{
//properties
String my_make;
String my_num;
int my_curPosx;
int my_curPosY;
int my_speed;
//building our car
car(String make, String num, int curX, int curY ){
my_make = make;
my_num = num;
my_curPosx = curX;
my_curPosY = curY;
}
/*........other methods ....*/
void drive(){
//calling this will make the car move
}
void stop(){
//calling this will stop the car
}
}