Javajunior level

2 questions pitched at this level, most-asked first.

  • Is Java pass-by-value or pass-by-reference?

    Java is always pass-by-value, with no exceptions. For an object the value copied is the reference, which is why a method can mutate your object but can never swap or replace it.

    Asked constantlyjunior0–6 yrs8 min readOop
  • What is the difference between String, StringBuilder and StringBuffer?

    String is immutable, so every change allocates a new one. StringBuilder is a growable buffer you mutate in place. StringBuffer is the same thing with every method synchronized, which you almost never need. Concatenating in a loop is the only case where the difference is dramatic — and it is dramatic.

    Asked constantlyjunior0–6 yrs9 min readStrings

Other levels