iven the following declaration int i1 = 1 int i2 = 2; String S1 = \"Hello\". Str
ID: 3603631 • Letter: I
Question
iven the following declaration int i1 = 1 int i2 = 2; String S1 = "Hello". String S2 = "HELLO" double d1 1.0; double d2 = 2; For each of the following comparisons, specify . Which are syntactically correct? .Which are syntactically incorrect? . Which are syntactically correct but logically questionable? Only specify the answer on the followingtable; an example is given Syntactically Syntactically Syntacticallycorrect, but incorrect parisons logically uestionable correct SI--"Hello == nu i1.equals(2) d1.equals(d2) (s1-s2).equals(null) s1.equals(s2)Explanation / Answer
i1 == i2 syntactically correct
d1 == d2 syntactically correct
s1 == "Hello" syntactically correct
s1 == s2 syntactically correct
s1 == d1 syntactically incorrect
i2-d2 == null syntactically incorrect
i1.equals(i2) syntactically incorrect
d1.equals(d2) syntactically correct
(s1-s2).equals(null) syntactically incorrect
i1-i2 == 0 syntactically correct
s1.equals(s2) syntactically correct
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.