GIAC
GSSP-JAVA · Question #2
John works as a Programmer for Technostar Inc. He writes the following code using Java. 1. class WrapperClass{ 2. public static void main(String[] argv){ 3. String str2 = Double.toString(12); 4…
The correct answer is C. It will compile and execute successfully and will display 0x1.8p312.0 as the output. See the full explanation below for the reasoning.
Question
John works as a Programmer for Technostar Inc. He writes the following code using Java. 1. class WrapperClass{ 2. public static void main(String[] argv){ 3. String str2 = Double.toString(12); 4. String str1 = Double.toHexString(12); 5. System.out.println(str1+str2); 6. } 7. } What will happen when John attempts to compile and execute the code?
Options
- AIt will not compile because the Double class does not contain the toHexString() method.
- BIt will compile and execute successfully and will display 8p312 as the output.
- CIt will compile and execute successfully and will display 0x1.8p312.0 as the output.
- DIt will not compile because the Double class does not contain the toString() method.
How the community answered
(35 responses)- A14% (5)
- B6% (2)
- C77% (27)
- D3% (1)
Community Discussion
No community discussion yet for this question.