Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.lang

 
arivu mathi
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • 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
 
wise owen
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
  • 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 ]
 
Vladimir Scheglov
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • 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
 
Pinkal Patel
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • 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");
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic