Question: In java all methods are pass by value.But today i learnt that constructors are pass by reference.

```
// Attack the internals of a Period instance
Date start = new Date();
Date end = new Date();
Period p = new Period(start, end);
end.setYear(78);  // Modifies internals of p!

```

This works and is able to edit the private fields.

What is the reason of this decision? or am i missing something?

Answer: 
You've got that wrong:

> 
> In java all methods are pass by value.
> 
> 
> 

Instead: In Java all parameters are passed by value, even references are passed by value. 

You don't "pass objects", only references to objects. This is the same for methods and constructors.

So 

```
end.setYear(78);  // Modifies internals of p!

```

does not change the reference but only the object the reference points to.
No, you aren't changing any private fields. The private fields in Period are not touched, they still reference the same object. Unfortunatly, a Date object is mutable. So you see the mutation through the Period object.

If you want to avoid this, make a copy of each object passed in the constructor, only thus you'll have your own Date objects no one outside of Period can modify.