Oracle
1Z0-803 · Question #36
Given: What is the result?
The correct answer is A. Compilation fails. The compilation fails as SampleClassA and SampleClassB cannot override SampleClass because the return type of SampleClass is int, while the return type of SampleClassA and SampleClassB is long. Note: If all three classes had the same return type the output would be: Hash is : 111
Java Basics
Question
Given:
What is the result?
Exhibit
Options
- ACompilation fails
- BAn exception is thrown at runtime
- CThere is no result because this is not correct way to determine the hash code
- DHash is: 111111, 44444444, 999999999
How the community answered
(23 responses)- A91% (21)
- B4% (1)
- C4% (1)
Explanation
The compilation fails as SampleClassA and SampleClassB cannot override SampleClass because the return type of SampleClass is int, while the return type of SampleClassA and SampleClassB is long. Note: If all three classes had the same return type the output would be: Hash is : 111111, 44444444, 999999999
Topics
#compilation error#object methods#hashCode#syntax
Community Discussion
No community discussion yet for this question.
