Question
Can someone help me with these questions.. Thank you. 1-Which of the following often has a void return type? a) Modification method b) instance variable
Can someone help me with these questions.. Thank you.
1-Which of the following often has a void return type? a) Modification method b) instance variable c) A "getter" d)Accessor method e) No-argument constructor
2-What is a good reason to define a static method?
a) To declare that the method always returns the same thing. b) To hide this method from the instances. c) To define an operation that doesn't start with any instance d) To define an efficient algorithm. e) To avoid modifying any variables.
3-The following definition for equality on locations has problems. Which criticism is unfair or wrong?
@Override boolean equals(Location other) { if (x == other.x && y == other.y) { return true; } else { return true; } } a) It always returns true. b) It should be declared public. c) It should use equals not == to compare the ints x and y. d) It will crash if passed null. e) It should take an Object parameter.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started