Question: **QUESTION**
How come this code here:
`Object y=x.remove();` removes the object from the queue?
Isn't this just a variable assignment. Why does it run the code, when we are not calling it? Does variable deceleration call the methods as well? 

```html
Queue<Integer> x = new LinkedList<Integer>();
    x.add(5);
    x.add(7)
    Object y=x.remove(); //<------THIS
    x.add(4)
    System.out.println(x.element());
```

Answer: 
On the right hand side of the = you have an expression. That expression is evaluated and the result is assigned to the variable on the left hand side. 

In your case that expression consists of a method invocation. That call to remove() returns the removed object. Which then gets assigned to y. And to be precise: the method removes the first element you added to the queue. 

That is all there is to this.
You are calling method of a queue class(.remove()). And this method remove the first element of the queue and return it. You can use peek method ( Object y=x.peek(); ), if you want to check the first element of the queue without removing it.