What is the relationship between hashCode() and equals()? What is the significance of these methods? What are the requirements for implementing them?
What is the difference between Set, Map and List?
I'm still amazed how many people don't know this one in a telephone interview.
Can an interface extend multiple interfaces?
Most people answer "no", because they know java doesn't have multiple inheritance. But an interface can still extend multiple interfaces (but a class can't extend multiple classes). This doesn't lead to the diamond problem.
If the answer is "no", the interviewer should ask "why would it be forbidden?". Then you start thinking about it and you should realize that there is not problem with it.
So you learned something (by yourself) in the interview and you showed the interviewer that you are able to reason about classes, objects, inheritance, polymorphism, etc. It's actually much better than a candidate who knows the answer by heart but doesn't understand why
Usage of final keyword in method calls.
For example why does the method test in below code does not give any compile error despite using final qualifier for the method parameter.
class Name {
private String name;
public Name (String s) {
this.name = s;
}
public void setName(String s) {
this.name = s;
}
}
private void test (final Name n) {
n.setName("test");
}
One sure is comparison of string. Difference between
String helloWorld = "Hello World";
helloWorld == "Hello World";
"Hello World".equals(helloWorld);
Trick question: What kinds of parameters are passed by reference in Java?
It's amazing how many people still parrot the "primitives are passed by value, objects are passed by reference" mantra.
You said "Good","Developer". Here are my 2 cents too.. :)
For J2EE:
I can think many, many, many more of 'em but this'll do for now :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With