Class Good has a field m and a method public boolean equals(Good n) { return n.m == m; }. In main: Good m1 = new Good(22), m2 = new Good(22); Object s1 = new Good(22), s2 = new Good(22); then it prints m1.equals(m2), s1.equals(s2), m1.equals(s2), s1.equals(m2). What is printed?
Pick an option to check yourself, or open the answer below.
Show answer & explanation
Correct answer: D. True, False, False, False C + + f(
Explanation
equals(Good) overloads rather than overrides Object.equals. Only m1.equals(m2) (both static type Good) calls it and gives true. The other three resolve to Object.equals, which compares references: false.
More Programming Languages and Computer Graphics questions
- Consider the following function ) : f n unsigned int (unsigned int )( b = 0 unsigned int ; while (n) { b+ = n&1 ; n ≫>= 1 ; } return b;} ``…
- Consider a raster system with resolution 640 by 480 . What size is frame buffer (in bytes) for this system to store 12 bits per pixel?
- Consider the following statements regarding 2D transforms in computer graphics: 1 0 [ ] 2 × 2 S1 : is a matrix that reflects 0 −1 2D X (mir…
- In the context of 3D computer graphics, which of the following statements is/are true? P : Orthographic transformations keep parallel lines…
- Using the phong reflectance model, the strength of the specular highlight is determined by the angle between
- If the frame buffer has 10-bits per pixel and 8- bits are allocated for each of the R, G, and B components, then what would be the size of…