A field default can be set at 'record field' properties of the record definition. Apart from this, If we talk about setting default value through code for a particular field, we use 'field default' peoplcode event.
Field Default peoplecode can be written at record field and component record field.
This event triggers peoplecode, only If the following conditions are all true.
1) The page field is still blank after applying any default value specified in the
record field properties.This is true if there is no default specified, if a null value is specified,
or if a 0 is specified for a numeric field.
2) The field has a FieldDefault PeopleCode program.