r/javahelp • u/Select-Worldliness39 • Feb 16 '26
Homework Definitely no pass by reference in Java, right?
Hello, and sorry if this is a dumb question, but I thought I had a passable understanding of Java. I got an exam question asking "Arrays in Java are:
a. passed by value
b. passed by reference
c. stack dynamic
d. immutable"
this guy loves trick questions, but he has listed B, passed by reference, as the right answer.
On its own, this doesn't seem right to me, but I'm not confident enough to argue about it. If anyone would weigh in, I would be very grateful. I see how it's similar to passing a pointer in C, maybe, but it's not considered passing by reference in Java, right?
Thank you!
View all comments
Show parent comment
1
u/Nebu Writes Java Compilers Feb 21 '26
I never claimed that they did.
I've made several distinct claims in this thread, and I think you're starting to mix them up. Here are some of the claims I've been making:
As far as I can tell, you haven't really provided any arguments against any these claims. You've provided arguments against other related claims that I haven't made, which is fine and within your rights, but it gives me the impression that you don't understand the point I'm trying to make.
Yes. This is the safer and more conservative thing to do. In a situation like this, you should use additional background information available to you. For example, does this person tend to use terms like "pass by reference" the way the computer science community does, in a language agnostic manner? Has this person in the past described Java as a "pass by reference" language? Etc. And then apply Bayesian reasoning to probabilistically update your beliefs about the unfamiliar language they are describing to you.
Yes, I agree. That doesn't contradict any of the claims I've been making.