code about introduction of java

http://deanzacollegecis.jenniferparrish.net/home/c…

link for activity7.1&7.2

http://deanzacollegecis.jenniferparrish.net/home/c…

link for activity8.1&8.2

http://deanzacollegecis.jenniferparrish.net/home/c…

link for lab4, it is the continue of lab3


Answer the following review questions from Lesson 7 by either typing directly into the textbox below or by uploading a document with your answers. Please include the question along with your answer to make your responses easy to read.

1. Encapsulation

a. Fill in the missing parts of the encapsulation definition: inclusion of ___________ into a _______ unit

b. How does the concept of encapsulation relate to defining a class in Java?

2. Information Hiding

a. Fill in the missing parts of the information hiding definition: hiding the ___________ that are most likely to _________ (a.k.a. data hiding)

b. Give two reasons that we should always make our class member variables private.

Reason 1:

Reason 2

The below class pertains to questions 3 – 5:

public class Address {
private int number;
private String street;
}

3. Add a toString method for the above class.

4. Add two mutator methods to the above class – setNumber and setStreet

5. Add two accessor methods to the above class – getNumber and getStreet

Answer the following review questions from Lesson 8 by either typing directly into the textbox below or by uploading a document with your answers. Please include the question along with your answer to make your responses easy to read.

1. Write two constructors for the below class:

    • A default constructor and a two-argument constructor

public class Address {

private int number;

private String street;

//write your two constructors here!

public int getNumber() {

return number;

}

public String getStreet() {

return street;

}

public void setNumber(int number) {

number = number;

}

public void setStreet(String street) {

street = street;

}

@Override public String toString() {

return number + ” ” + street;

}

}

2. There is a problem with the above mutator methods. Correct the problem.

3. How many distinct Dog objects are created in the below program:

public static void main(String[] args) {

Dog d1 = new Dog(“Fluffy”, 10);

Dog d2 = d1;

System.out.println(d2);

Dog d3 = new Dog(d2);

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

Dog d4 = d3;

Dog d5 = d4;

d4 = new Dog(“Brutus”, 80);

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

Dog d6 = new Dog();

d6 = d4;

}

"Is this question part of your assignment? We can help"

ORDER NOW