exam questions

Exam 1z0-808 All Questions

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

Exam 1z0-808 topic 1 question 25 discussion

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

Given the code fragment:

Which two modifications, when made independently, enable the code to print joe:true: 100.0? (Choose two.)

  • A. Option A
  • B. Option B
  • C. Option C
  • D. Option D
  • E. Option E
Show Suggested Answer Hide Answer
Suggested Answer: AC 🗳️

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
abhayshitole
1 month, 2 weeks ago
Selected Answer: AD
A and D are correct. With C you will get compilation error that 'this' cannot be referenced from a static context
upvoted 1 times
...
TheeOne
2 months, 3 weeks ago
Selected Answer: AD
AC and D are all correct
upvoted 1 times
...
vic88
4 months, 2 weeks ago
Selected Answer: AC
AC, but the C Boolean(true) is deprecated sinceJava 9.
upvoted 1 times
...
MPignaProTech
5 months, 2 weeks ago
Selected Answer: AC
AC is the correct answer
upvoted 1 times
...
7df49fb
1 year, 1 month ago
AC the last line in main method should be : System.out.print(e.toString();
upvoted 1 times
...
arjunrawatirissoftware
1 year, 6 months ago
Answer - A and C
upvoted 1 times
...
somrita90
1 year, 7 months ago
A is correct, C is incorrect, boolean is not same as Boolean, so this.contract = new Boolean("True"); is a compilation error for. D can be the another correct option if we are writing true instead of TRUE. Other than this none of these are correct.
upvoted 1 times
...
KeletsoM23
1 year, 9 months ago
Why is D not correct?
upvoted 1 times
PedroC123
1 year, 7 months ago
Because its true and not TRUE.
upvoted 1 times
...
...
felipegomeztreufo
1 year, 10 months ago
Respuesta correcta es A, recordar que esta en un cotexto estatico por lo que no puede acceder con this ni menos con con la nombre de la variable
upvoted 1 times
...
Kolodets
1 year, 12 months ago
AC or AD - both correct
upvoted 3 times
...
Vicky_65
2 years ago
Selected Answer: AC
A and C
upvoted 1 times
...
anmoldev2java
2 years, 5 months ago
Selected Answer: AC
a and c are correct
upvoted 1 times
...
carloswork
2 years, 6 months ago
Selected Answer: AC
Tested. Answer is A and C. Comments: * Option C works even though it has been deprecated since version 9 (1z0-808 is about java 8). ** Option B would only be correct if it is inside the constructor, on line n1. As option B is pointing to line n2, it will throws an error.
upvoted 2 times
carloswork
2 years, 6 months ago
Here is the code for testing: public class Employee { String name; Boolean contract; double salary; Employee(){ // Line n1 - Option C /* this.name = new String("Joe"); this.contract = new Boolean(true); this.salary = new Double(100); */ } public String toString() { return name + " : " + contract + " : " + salary; } public static void main(String [] args) { Employee e = new Employee(); // Line n2 - Option A /* e.name = "Joe"; e.contract = true; e.salary = 100; */ // Line n2 - Option B /* this.name = "Joe"; this.contract = true; this.salary = 100; */ System.out.print(e); } }
upvoted 3 times
...
...
iSnover
2 years, 6 months ago
Selected Answer: AC
The correct options are A and C, as all others contain syntax errors. It cannot be the letter B because "this" cannot be instantiated in static methods.
upvoted 1 times
...
alex_au
2 years, 6 months ago
Should be A, C. We cannot do B as we cannot use "this" in the static method
upvoted 2 times
...
RoxyFoxy
2 years, 7 months ago
Selected Answer: AB
If C, unnecesary boxing to Boolean and Double. If we use "new" we will create new objects.
upvoted 1 times
iSnover
2 years, 6 months ago
Wrong, you can't put "this" in static methods. The correct one is A and C.
upvoted 3 times
Kolodets
1 year, 12 months ago
wrong, it is A, C and D
upvoted 2 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 ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago