Question: Week 005 Procedure: MAKE NetBeans project for this activity. 1.A simple java program with the following specifications: a.In the main method add the following declarations:

Week 005

Procedure:

MAKE NetBeans project for this activity.

1.A simple java program with the following specifications:

a.In the main method add the following declarations:

int[ ] arr1 = {1,2,3,4,5,6,7,8,9,10};

int[ ] arr2 = {10,9,8,7,6,5,4,3,2,1};

int[ ][ ] arr3 ={{1,2,3},{4,5,6},{7,8,9},{10}};

System.out.print(arr1[0]);

b.Save, compile and run the program.

Test Stem / Question

Choices

1: What is the output when you run the program?

A: 0

B: 1

C: 2

D: None of the above

2: What is the value of: arr3[arr1[0]][arr2[arr1[8]]]

A: 5

B: 6

C: 7

D: None of the above

3: What is the value of: arr3[2][arr1[1]]

A: 7

B: 8

C: 9

D: None of the above

4: What is the value of: arr1[arr2[arr1[arr2[3]]]]

A: 1

B: 2

C: 3

D: None of the above

5: What is the value of: arr1[x++]

A: 1

B: 2

C: 3

D: None of the above

c.

2.Add the following codes at the end of your main method:

for(int x=1; x<=5;x++) System.out.print(arr1[5-x]);

a.Save, compile and run the program.

Test Stem / Question

Choices

6: What is the output when you run the program?

A: 12345

B: 54321

C: 678910

D:1098765

E: None of the above

7: What would be the output if you arr2[5-x] instead of arr1[5-x];

A: 12345

B: 54321

C: 678910

D:1098765

b.

3.Open the file again and modify add the following codes in the main method:

for(int x = 0; x<10; x++)

{

arr1[x]=arr2[x];

arr2[x]=x;

}

System.out.print(arr2[0]);

a.Save, compile and run the program.

Test Stem / Question

Choices

8: What is the output when you run the program?

A: 0

B: 1

C: 2

D: None of the above

9: What is the value of: arr3[arr1[0]][arr2[arr1[8]]]

A: 5

B: 6

C: 7

D: None of the above

10: What is the value of: arr3[2][arr1[1]]

A: 7

B: 8

C: 9

D: None of the above

Week 007

Procedure:

Make NetBeans project for this activity.

1.A class that contains an address book entry and name it AddressBook.

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

b.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 make an instance of AddressBook class?

A: AddressBook addressBook;

B: addressBook addressBook = new addressBook();

C: addressBook addressBook = new addressBook;

D: None of the above

4.

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

}

}

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

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

AddressBook addressBook2 = new AddressBook();

addressBook2.setName("Mary");

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

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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!