Win a copy of Head First Android this week in the Android forum!

sumi selva

Greenhorn
+ Follow
since Jul 10, 2007
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by sumi selva

Hi,
I have SCJP voucher #310 valid till june-2008(Bought in India). Its price is Rs 5100. If any one is interested, can contact me at vadani_slm@rediffmail.com

Vadani
13 years ago
Hi,

I was preparing scjp 1.5 for the past 6 months.I got a discount voucher from my friend and took the exam on Aug 30th.But didnt clear the exam.I jus scored 47% and time was not sufficient.I didnt attend ten questions in the exam due to lack of time.I didnt take any mock exams priorer to the main exam.I felt so bad and feel like I should have taked 1.4 exam.

Now I'm in a confusion whether to start preparing for 1.4 and take the exam or start preparing well for 1.5 and take the exam after 1yr.

Please give me some inputs on this.

Thanks,
Sumi
I executed the following code.
import java.util.*;

class DemoPQ {
public static void main(String[] args) {
PriorityQueue<String> pq = new PriorityQueue<String>();
pq.add("Ravi");
pq.add("Kumar");
pq.add("Sumit");
pq.add("Vineet");
pq.add("Amit");

for(String s q) {
System.out.print(pq.peek() + ", " + pq.poll());

}
}

}

Got the output as Amit followed by ConcurrentModificationException.
May I know why does this exception come?

Thanks,
Sumi
Hi,
Thank you very much.Now got cleared.

Thanks,
Sumi
Hi, I executed the following code and got the output as : success
I could not understand the output.since we call the equals method of the object class, which is not overriden.It should return Failed.But why does it gives success as output.could anyone explain me clearly about the equals.

public static void main(String[] args) {
String s = new String("hi");
Object o = new String("hi");
if(o.equals(s)) {
System.out.println("success");
} else {
System.out.println("Failed");
}
}

If the lines has been
String s1 = new String("hi");
String s2 = new String("hi");
then it means only one string obj is created and both s1 ans s2 refer to it.so equals shud retruns true since it has overridden.

But in the above example, we call the equals on object class which does not override equals..so actually two objects are created.but how come it retirns that they are equal?

Thanks,
Sumi
Hi,

And also there is a booleanValue () method in java.lang.Boolean class.Think that shud also be corrected.


Thanks,
Sumi
Hi,

I tried the following code and it compiles fine
Boolean b = Boolean.parseBoolean("true");
But In K&B, p-233, its given as parseXxx(without radix) is not for Boolean and Character.

So think there is a typo in the page

Thanks,
Sumi
Hi,
Is getAbsolutepath and path related stuffs are included in scjp 1.5 exam
Could anyone tell me

Thanks,
Sumi
Hi,

I ran this code.But I'm getting only "Diff object" as output.
Could anyone explain.

Integer i3 = 10;
Integer i4 = 10;
i3 = i3 + 1;
if(i3 != i4) System.out.println("diff object");
if(i3.equals(i4)) System.out.println("meaningfully equal");

Thanks,
Sumi
Hi All,
One more thing to add..

Given in K&B - Chap 2
"when a subclass-outside-the-package inherits
a protected member, the member is essentially private inside the subclass, such
that only the subclass and its subclasses(both in the same and different package)can access it."

Thanks,
Sumi
Hi All,
I got the answer.
If the variable is a static protected one it can be accessed through dor operator in another package.
If it is a protected one without static modifier, it can be accessed only thr inheritance in another package.

Thanks,
Sumi
Hi All,
I compiled the below code and didnt get any compile error.It runs fine.
But as per K&B, it should produce a compile error.

Code
------
package A;
public class Father{
static public int x1 = 7;
static protected int x2 = 8;
static int x3=9;
static private int x4 =10;
}

package B;
import A.Father;

public class Son extends Father{

public static void main(String [] arg){
Father f = new Father();
System.out.println( f.x2 );
}
}

May I know why this compiles fine?


Thanks
Sumi
Hi,
could anyone tell me from where does the outout come.
There is no system.out.print statement in the code.What is actually printed


Sumi
Hi,

I tried the following code
class Test {
static int x ; ---> line 1
x = 3;
public static void main(String[] args) {

}
}

even if I substitute int x (or) final int x (or) final static int x
I get a compile error.

Should a instance variable always be a compile time constant.cant we assign them values at runtime.

Thanks,
Sumi
Hi,

I am a bit confused with the code.
If we uncomment the below lines

int i = getFeet();
static int getFeet(){
System.out.println("instance variable initialization");
return 1;
}

We get the o/p as
Constructor invoked
Arg Constructor completes
No-arg constructor completes

Till this I can understand, but if we uncomment the line we get a different output.
I would like to know, from where the getFeet() method is called.It is only a method and not a static block.

Thanks,
Sumi