Skip to content
This repository has been archived by the owner on May 7, 2023. It is now read-only.

Java Questions #95

Closed
skatcat31 opened this issue Aug 3, 2018 · 3 comments
Closed

Java Questions #95

skatcat31 opened this issue Aug 3, 2018 · 3 comments

Comments

@skatcat31
Copy link
Contributor

I was recently in an interview where I was asked "What is the difference between .equals and == when comparing Objects in Java?" that I thought would be a good example to highlight here. I do however want to think of the best way to go about it. To that end I've thought of two problems with it currently that should be addressed before submission:

  • Should we expand this question to cover more languages?
  • Should we consider this a Java specific question and host questions like it for other languages?
@skatcat31
Copy link
Contributor Author

Expanding the question:

How would you compare two objects to check for different types of equality?

Equality can mean many things, but primarily in computer science there are two ways to check for equality with Objects:

  • By Value
  • By Reference

By Value

Checking equality by value means to see if the second Object stores an equivalent value. In Java this is done with the .equals method, and in JavaScript this is done with loose evaluation(==)

By Reference

Checking equality by reference means to see if the second Variable resolves to the same Object in memory. In Java this is done on Objects with == and in JavaScript with strictly equal to(===)

@skatcat31
Copy link
Contributor Author

Otherwise the other option is to add tags for languages and put this as an example in each with the differences per language highlighted against a 'base' language(probably JavaScript since this is a full stack resource)

@fejes713
Copy link
Collaborator

fejes713 commented Aug 6, 2018

Thanks for pointing this out @skatcat31

We have discussed this in the early days of 30 seconds of interviews and there were mixed opinions on this topic.

In general, this is a great idea. It makes sense to have different answers for different programming languages. However, our interview question database is not very big ~80 questions.

Personally, I am against adding material that is not in the scope of modern full-stack web development for now. Mainly because, as I said, we have ~80 questions and it is not worth it.

@fejes713 fejes713 closed this as completed Aug 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants