This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes java.lang Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "java.lang" Watch "java.lang" New topic
Author

java.lang

arivu mathi
Ranch Hand

Joined: Jun 26, 2006
Posts: 38
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

Joined: Feb 02, 2006
Posts: 2023
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

Joined: Jun 19, 2006
Posts: 20
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

Joined: Jun 16, 2006
Posts: 57
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");


Pinkal Patel<br />SCJP 1.5<br />Preparing for SCWCD
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: java.lang
 
Similar Threads
parseFloat and Float.NaN??
Exception Handling
Find the unreachable statement in this code
Exam on Monday -- pl help
exception flow