Create a class that contains an address book entry and name it AddressBook. The table below describes the information that an address book entry has. Attributes/Field Description Name Name of the person in the address book Address Address of the person Mobile Number Mobile number of the person Email Address Email address of the person The class definition should contain the following: Attributes Constructor Accessors and mutators Test Stem / Question Choices 1: How many attributes should be defined in AddressBook class? A: 1 B: 2 C: 3 D: 4 E: None of the above 2: How many accessors should be defined in AddressBook class? A: 1 B: 2 C: 3 D: 4 E: None of the above 3: How many mutators should be defined in AddressBook class? A: 1 B: 2 C: 3 D: 4 E: None of the above
- Create a class that contains an address book entry and name it AddressBook.
- The table below describes the information that an address book entry has.
Attributes/Field |
Description |
Name |
Name of the person in the address book |
Address |
Address of the person |
Mobile Number |
Mobile number of the person |
Email Address |
Email address of the person |
- The class definition should contain the following:
- Attributes
- Constructor
- Accessors and mutators
Test Stem / Question |
Choices |
1: How many attributes should be defined in AddressBook class? |
A: 1 |
B: 2 |
|
C: 3 |
|
D: 4 |
|
E: None of the above |
|
2: How many accessors should be defined in AddressBook class? |
A: 1 |
B: 2 |
|
C: 3 |
|
D: 4 |
|
E: None of the above |
|
3: How many mutators should be defined in AddressBook class? |
A: 1 |
B: 2 |
|
C: 3 |
|
D: 4 |
|
E: None of the above |
|
4: What is the name of the Constructor? |
A: AddressBook |
B: AddressBook() |
|
C: public AddressBook |
|
D: None of the above |
|
5: How do you create an instance of AddressBook class? |
A: AddressBook addressBook; |
B: addressBook addressBook = new addressBook(); |
|
C: addressBook addressBook = new addressBook; |
|
D: None of the above |
- Create another class and add the following codes:
public class AddressBookTest()
{
public static void main(String args[])
{
AddressBook addressBook1 = new AddressBook();
addressBook1.setName("John");
System.out.println(addressBook1.getName());
}
}
- Save, compile and run the program.
Test Stem / Question |
Choices |
6: What will happen if you run the AddressBook class? |
A: It will output “John” |
B: It will output “Name: John” |
|
C: It will output “Hello World!” |
|
D: It will output “Hello John!” |
|
E: None of the above |
|
7: What is the output when you run the AddressBookTest class? |
A: It will output “John” |
B: It will output “Name: John” |
|
C: It will output “Hello World!” |
|
D: It will output “Hello John!” |
|
E: None of the above |
- Modify the AddressBookTest by adding the following codes in main method:
AddressBook addressBook2 = new AddressBook();
addressBook2.setName("Mary");
System.out.println(addressBook1.getName());
- Save, compile and run the program.
Test Stem / Question |
Choices |
8: What is the output when you run the AddressBookTest class? |
A: It will output “John” |
B: It will output “Name: John” |
|
C: It will output “Hello World!” |
|
D: It will output “Hello John!” |
|
E: None of the above |
|
9: How many instances of AddressBook are there in the AddressBookTest class? |
A: 0 |
B: 1 |
|
C: 2 |
|
D: 3 |
|
E: None of the above |
|
10: What type of method is setName()? |
A: Constructor |
B: Destructor |
|
C: Accessor |
|
D: Mutator |
|
E: None of the above |
Trending now
This is a popular solution!
Step by step
Solved in 2 steps