exam questions

Exam 1z0-808 All Questions

View all questions & answers for the 1z0-808 exam

Exam 1z0-808 topic 1 question 75 discussion

Actual exam question from Oracle's 1z0-808
Question #: 75
Topic #: 1
[All 1z0-808 Questions]

Given:

What is the result?

  • A. true:true
  • B. true:false
  • C. false:true
  • D. false:false
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
dya45792
Highly Voted 5 years, 6 months ago
Antwort C, ist richtig public class Product { int id; String name; public Product (int id, String name) { this.id = id; this.name = name; } public static void main(String[] args) { Product p1 = new Main (101, "Pen"); Product p2 = new Main (101, "Pen"); Product p3 = p1; boolean ans1 = p1 == p2; boolean ans2 = p1.name.equals(p2.name); System.out.println(ans1 + " : " + ans2); } } false : true
upvoted 18 times
...
JoseCG
Highly Voted 5 years, 8 months ago
Correct.
upvoted 7 times
...
MPignaProTech
Most Recent 8 months ago
Selected Answer: C
Correct answer is C, code for testing:
upvoted 1 times
...
98Rohitsahu
1 year, 7 months ago
Correct Answer is C.
upvoted 1 times
...
dsms
1 year, 10 months ago
correct answer is C: false:true
upvoted 1 times
...
dsms
1 year, 10 months ago
Selected Answer: C
boolean ans1 = p1 == p2; // false - because p1 and p2 is two different objects boolean ans2 = p1.name.equals(p2.name); // true
upvoted 1 times
...
Vicky_65
2 years, 2 months ago
Selected Answer: C
correct one is C
upvoted 1 times
...
CreazyyyyGirl
2 years, 3 months ago
Selected Answer: C
C is correct
upvoted 1 times
...
Solliii
2 years, 3 months ago
Selected Answer: D
tested: class Product { int id; String name; public Product(int id, String name) { this.id = id; this.name = name; } public static void main(String[] args) { Product p1 = new Product(101, "Pen "); Product p2 = new Product(101, "Pen"); Product p3 = p1; boolean ans1 = p1 == p2; boolean ans2 = p1.name.equals(p2.name); System.out.print(ans1 + " " + ans2); } }
upvoted 1 times
Mtandwa
1 year, 11 months ago
Unfortunately you added a space after Pen in p1 that's why the answer came out as false. answer is C
upvoted 1 times
...
...
Ripfumelo
2 years, 5 months ago
The answer is C:tested and proven
upvoted 1 times
...
haisaco
2 years, 6 months ago
Selected Answer: C
c is correct
upvoted 1 times
...
anmoldev2java
2 years, 7 months ago
Selected Answer: C
c is correct
upvoted 1 times
...
carloswork
2 years, 8 months ago
Selected Answer: C
Answer is C. class Product { int id; String name; public Product(int id, String name) { this.id = id; this.name = name; } public static void main(String[] args) { Product p1 = new Product(101, "Pen"); Product p2 = new Product(101, "Pen"); Product p3 = p1; boolean ans1 = p1 == p2; boolean ans2 = p1.name.equals(p2.name); System.out.print(ans1 + " " + ans2); } }
upvoted 1 times
...
DiamondWhite
2 years, 11 months ago
Selected Answer: D
Actually it's false false, because the first name has a white space "Pen ".. while the other name is "Pen"..
upvoted 1 times
DiamondWhite
2 years, 11 months ago
Oops ignore my comment...
upvoted 2 times
...
...
neredynerd
2 years, 11 months ago
Selected Answer: D
Answer D false false checked class Product { int id; String name; public Product(int id, String name) { this.id = id; this.name = name; } public static void main(String[] args) { Product p1 = new Product(101, "Pen "); Product p2 = new Product(101, "Pen"); Product p3 = p1; boolean ans1 = p1 == p2; boolean ans2 = p1.name.equals(p2.name); System.out.print(ans1 + " " + ans2); } }
upvoted 1 times
DiamondWhite
2 years, 11 months ago
You have a white space in the first name "Pen "
upvoted 2 times
...
...
Bradleyyeo
3 years, 3 months ago
equals method not overriden so should be false:false right?
upvoted 1 times
shivkumarx
2 years, 9 months ago
ans2 is comparing the name property not the object itself so its true that "Pen".equals("Pen")
upvoted 1 times
...
Ghamm
1 year, 7 months ago
Yes, i am agree with you. But when I compiled the correct option is C only.
upvoted 1 times
...
...
Yogesh_gavate19
3 years, 11 months ago
false false
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...