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

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 7PE
icon
Related questions
Question
  1. Create a class that contains an address book entry and name it AddressBook.
    1. 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

 

  1. The class definition should contain the following:
  1. Attributes
  2. Constructor
  3. 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

  1.  

 

  1. 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());

  }

}

  1. 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

 

 

  1. Modify the AddressBookTest by adding the following codes in main method:

    AddressBook addressBook2 = new AddressBook();

    addressBook2.setName("Mary");

    System.out.println(addressBook1.getName());

  1. 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

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,