address book holds a collection of entries, each recording a person's first
and last names, address, city, state, zip, and phone number.
It must be possible to add a new person to an address book, to edit existing
information about a person (except the person's name), and to delete a
person. It must be possible to sort the entries in the address book
alphabetically by last name (with ties broken by first name if necessary), or
by ZIP code (with ties broken by name if necessary). If a person lives in an
urban area, your program must follow the metropolitan address format (e.g.
House Number 5, Street 12, Sector G-8, city, PostCode: 12345). If a
person lives in a rural area, your program must follow the rural address
format (e.g. Village Topi, PO Topi, Tehsil Sawabi, Distt Sawabi, KPK,
PostCode: 12345.)
It must be possible to create a new address book, to open a disk file
containing an existing address book to close an address book, and to save an
address book to a disk file, using standard New, Open, Close, Save and
Save As ... File menu options

this is gonna come for my examination and i need the code to prepare for it

Nobody here is going to give you the code for your exams, and shame on you for asking.
Now, do you have a specific question about Java that we can help you with?