Set - 8

Question 51 :

What's the difference between a queue and a stack?

Answer :

Stacks works by last-in-first-out rule (LIFO), while queues use the FIFO rule


Question 52 :

What comes to mind when you hear about a young generation in Java?

Answer :

Garbage collection.


Question 53 :

You can create an abstract class that contains only abstract methods. On the other hand, you can create an interface that declares the same methods. So can you use abstract classes instead of interfaces?

Answer :

Sometimes. But your class may be a descendent of another class and in this case the interface is your only option.


Question 54 :

What comes to mind when someone mentions a shallow copy in Java?

Answer :

Object cloning.
If you're overriding the method equals() of an object, which other method you might also consider?
hashCode()


Question 55 :

You are planning to do an indexed search in a list of objects. Which of the two Java collections should you use: ArrayList or LinkedList?

Answer :

ArrayList