• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

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");
 
Why fit in when you were born to stand out? - Seuss. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic