+ Follow
since Aug 01, 2000
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Hema

Is there any function in Java that will help in round a floating point number to specific no of decimals?
Example: when rounding 3.1237 to 3 decimals the result shoud be 3.124 and 3.1233 should be 3.123.
Math.round() doesn't seem to do that.
All suggestions and pointers are highly appreciated.

21 years ago
I'm a Sun certified Java programmer with 3 years of experience in IT industry and about one year of experience in java AWT/SWING, Servlets,JDBC.
I'm open for Java developer positions in & around BayArea, CA.
Currently I'm in a H4 Visa & need a H1 sponsorship.
You can view my resume at http://resumes.dice.com/hema_s
Mail me at hema_s@yahoo.com, if you need a copy of my resume in Word Format.
21 years ago
Hi JavaRanch,
I passed the exam today with 81%. I know my weakness with multiple choice answers let me down with the percentage. Well, No regrets...
The test was easy , closest to Marcus Green exams & Jxam test.
I got all the famous String-append,Media tracker & Socket questions. I'm sure I got it all right thanks to you guys.
I prepared for 3 weeks with the help of RHE/Cram. Took my own notes & peeked in to Aman & Carl's notes during last minute preps. Did couple of mocks in Maha's site & visited this forum regularly.
My special thanks to Ajith & all the moderators who have helped me directly/indirectly in making this possible.It's impossible to fail if you frequent this saloon.
I'll hang around here for some more time...
Classes that implements Datainput are
DataInputStream & RandomAccessFile
The ones that implements DataOutput are
DataOutputStream & RandomAccessFile
And they have methods to read/write all primitives.
Try running this code, you can definetly say C is correct .
import java.awt.*;
public class Layoutframe extends Frame {
public Layoutframe(){
Button b = new Button("What is my location?");
Panel p1 = new Panel();
public static void main(String[] arg){
Layoutframe lay= new Layoutframe();
Hi Sanjeet,
18) Primitive type wrapper classes:
a) Allow primitive types to behave as reference types
b) Allow operator overloading to be implemented for primitive numeric types
c) Provide string parsing and conversion methods
d) Provide arithmetic operators such as plus and minus
e) Are provided for all primitive types, including void
your answer was : a c e
You answer is correct. There is a Void wrapper class.
21) Methods for a Component are:
a) add()
b) setbounds()
c) setVisible()
d) setEnabled()
e) addComponent()
your answer was : b d
The answer is b,c,d. Please refer Exam cram , it lists the methods of Component& Container. b,c, d are component methods.
a is container method & there is no method called addcomponent().
however there are container methods getComponentCount() & getComponentAt(int x, int y).
I hv a doubt with yr other question.

23) Based upon the code below, what is true about the Applet constructed?
1. public LayoutApplet ( ) {
2. setLayout(new BorderLayout());
3. setFont(new Font("Serif", Font.PLAIN, 14));
4. add(BorderLayout.NORTH, new Button("North"));
5. add(BorderLayout.SOUTH, new Button("South"));
6. add("East", new Button("East"));
7. add("West", new Button("West"));
8. add(new Button("Center"));
9. }
a) Statement 2 is ignored and the default Layout Manager for an Applet is used.
b) There is a compile error on line 6: you cannot mix the use of Strings and Constants to specify the location of components.
c) There is a compile error on line 8: the location specification via a String or Constant is not provided.
d) Five push buttons are drawn, with the largest push button in the center.
e) The code compiles successfully
your answer was d ,e.
I tried compiling & running this code.
import java.awt.*;
import java.applet.Applet;
public class Layoutapplet extends Applet {
public void init(){
setLayout(new BorderLayout());
setFont(new Font("Serif", Font.PLAIN, 14));
add(BorderLayout.NORTH, new Button("North"));
add(BorderLayout.SOUTH, new Button("South"));
add("East", new Button("East"));
add("West", new Button("West"));
add(new Button("Center"));
And I got the 4 buttons . But there is no center button which says "Center". Can you explain..?

Hi Sdev,
I'm a novice myself, but here is how I do the shifting.
Refer RHE, It says
If a binary number is shifted left one position, the effect of the shift is to double the original number. So the result is as if the number is multiplied by 2,4, 8,16 & so on.
Similarly in shifting right , the result is as if the number is
divided by 2, 4, 8 & so on..Please note, the case is different for negative numbers.
If we take yr case, (byte)0x81>>2
1.Convert 0X81 to decimal. The equivalent decimal value is 129.
2.Shifting 129 >> 2, is equivalent to dividing 129 by 4. The
value will be 32 (not 32.5)
3. Convert 32 to Hex. The value will be 0X20.
So the answer will be the choice a. 0X20
Please feel free to correct me if I am wrong.

Take the lines,
14: Base b = new Derived1 ();
15: Derived1 d1 = new Derived1();
16: Derived2 d2 = new Derived2();
17: b = (Base) d1;
18: b = (Base) d2;
14: Base b = new Derived1 (); // This is legal, apply the conversion rule, the new class shuld be a superclass of the old class.
15: Derived1 d1 = new Derived1(); // Legal
16: Derived2 d2 = new Derived2(); //Legal
17: b = (Base) d1; // This is casting is legal , because you hv already assigned Derived1 to Base in Line 14.
18: b = (Base) d2;// Illegal.This attempts a (runtime) cast of Derived2 to Base, whereas Base is already assigned to Derived1.
So you'll get a Runtime Exception.
( This culd hv been legal, if there is statement which says,
Base b = new Derived2 ();
Hope this helps.
Thanks guys,I got the point.
Can you tell me the funda behind this conversion ? I see from the book that Octal is prefixed with O & Hex is prefixed with OX,
Suppose if we take the same example as in RHE for 28,
How do we get this Hex conversion 0x1C & octal of 034 ?
Thanks Ajith,
That really helped & I'm very CLEAR now.
Got to do lot of reading.
Hi Ajith,
I'm taking my exam this month end & preparing with the help
of this thread & the book " Java cert study guide- Robert, Heller".
In this book, chapter 6- Objects & classes covers the
inner classes.It has a sub heading , "Static Inner Classes"
which states "Java allows an inner class to be marked Static"
But what I infer from yr reply to Deepak is that there is no
static inner class in java, instead it shuld be called
top level nested class.
Is that what you mean ?