Integer i = new Integer (42); Long 1 = new Long (42); Double d = new Double (42.0); Which two expressions evaluate to True? (Choose Two) A.(i ==1) B.(i == d) C.(d == 1) D.(i.equals (d)) E.(d.equals (i)) F.(i.equals (42))
i got answer until i compile and refer JDK API Documents.So notice such question.
Thank Folks who <b>Make Sense</b> here.<br />SCJP Platform 2
First the name of the reference variable of type Long is l (el) not 1 (one). The latter is not a legal identifier. Then, A, B and C all yield false since all reference variables are different (created with new). D and E yield false too since Double.equals() expects an argument of type Double and Integer.equals() expects an argument of type Integer. F is false too since equals() expects an object and not a primitive. To summarize, statements A B C F will not compile. D E compile and when run yield false. So this question is wrong.
Only D and E are correct statement but return false...rests are wrong statements....So no statement return true. Believe me, u'll not face such weird question in the real exam. I found so many such weird question in the mock test...but did'nt face in the real exam.... But, really, these are need for self development and confidence
Nazmul<br />SCJP,SCWCD,IBM OOAD with UML
Acetylsalicylic acid is aspirin. This could be handy too: