• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

java.lang

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Given the following,
1. public class WrapTest3 {
2. public static void main(String [] args) {
3. String s = "98.6";
4. // insert code here
5. }
6. }
which three lines inserted independently at line 4 will cause compiler errors? (Choose three.)
A. float f1 = Float.floatValue(s);
B. float f2 = Float.valueOf(s);
C. float f3 = new Float(3.14f).floatValue();
D. float f4 = Float.parseFloat(1.23f);
E. float f5 = Float.valueOf(s).floatValue();
F. float f6 = (float) Double.parseDouble("3.14");


plz explain the output
 
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why not just enter the code into a program and test it. You can figure it out. Most are relative to Java api.
By the way, I only have A & D (two) in Java5.
[ June 28, 2006: Message edited by: wise owen ]
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
float f1 = Float.floatValue(s); //non-static method floatValue
float f2 = Float.valueOf(s); //right only for J2SE 5.0
float f3 = new Float(3.14f).floatValue(); //right
float f4 = Float.parseFloat(1.23f); //for parseFloat need String
float f5 = Float.valueOf(s).floatValue(); //right
float f6 = (float) Double.parseDouble("3.14");//right
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A. float f1 = Float.floatValue(s); floatValue(STRING) method is not exist in FLoat class
B. float f2 = Float.valueOf(s);valueOf Methos return Float object not premitive float
C. float f3 = new Float(3.14f).floatValue();
D. float f4 = Float.parseFloat(1.23f);Float.parseFloat(String) Excpecting input type String not float
E. float f5 = Float.valueOf(s).floatValue();
F. float f6 = (float) Double.parseDouble("3.14");
 
If you two don't stop this rough-housing somebody is going to end up crying. Sit down and read this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic