since May 07, 2009

For More

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

Ranch Hand Scavenger Hunt

Greenhorn Scavenger Hunt

Hi All,

I have cleared SCJP with 91% today!

I joined this forum just a few days back and am very thankful to all ranchers who helped me by answering my queries.

A special thanks goes to Devaka Cooray for his wonderful Examlab tool [Btw,i never cleared any of his mocks , got only 55% in the final exam]. But it just motivated me to study harder.

And last but not the least,i am grateful to have got my hands on K & B book, which is the best book for studying SCJP.

The real Sun exam was easier compared to K&B mocks and Examlab.

Its party time now after 3 weeks of hard work

Thanks,

Aditi.

I have cleared SCJP with 91% today!

I joined this forum just a few days back and am very thankful to all ranchers who helped me by answering my queries.

A special thanks goes to Devaka Cooray for his wonderful Examlab tool [Btw,i never cleared any of his mocks , got only 55% in the final exam]. But it just motivated me to study harder.

And last but not the least,i am grateful to have got my hands on K & B book, which is the best book for studying SCJP.

The real Sun exam was easier compared to K&B mocks and Examlab.

Its party time now after 3 weeks of hard work

Thanks,

Aditi.

15 years ago

Henry and Byju,

Thanks a lot for your answers.

I was thinking that the start() method returns the first element of the group.I was obviously wrong.Thanks again.

Thanks,

Aditi

Thanks a lot for your answers.

I was thinking that the start() method returns the first element of the group.I was obviously wrong.Thanks again.

Thanks,

Aditi

15 years ago

Hi All,

This is a question from K&B master exam

import java.util.regex.*;

class Regex2{

public static void main(String args []){

Pattern p = Pattern.compile(args[0]);

Matcher m = p.matcher(args[1]);

boolean b = false;

while (b = m.find()) {

System.out.println(m.start() + m.group() + "");

}

}

}

And the invocation java Regex2 "\d\s\w" "12s 4 w 33 1"

produces the output 44 w and 93 1

Now,since the 2 groups found are "4 w" and "3 1",i understand that the first part of the output is "44 w".

Along the same lines,the 2nd part of the output should have been "33 1".

can someone explain how is it "93 1"?

Thanks,

Aditi.

This is a question from K&B master exam

import java.util.regex.*;

class Regex2{

public static void main(String args []){

Pattern p = Pattern.compile(args[0]);

Matcher m = p.matcher(args[1]);

boolean b = false;

while (b = m.find()) {

System.out.println(m.start() + m.group() + "");

}

}

}

And the invocation java Regex2 "\d\s\w" "12s 4 w 33 1"

produces the output 44 w and 93 1

Now,since the 2 groups found are "4 w" and "3 1",i understand that the first part of the output is "44 w".

Along the same lines,the 2nd part of the output should have been "33 1".

can someone explain how is it "93 1"?

Thanks,

Aditi.

15 years ago

Alexander,

Thanks for the reply.

Can anyone confirm if questions of this type are present in the SUN exam?Also,any different approach to tackle this question?

Thanks,

Aditi.

Thanks for the reply.

Can anyone confirm if questions of this type are present in the SUN exam?Also,any different approach to tackle this question?

Thanks,

Aditi.

15 years ago

Hi All,

This is a question from Devaka's final exam.

How many objects are eligible for GC after line 17?

1. class A{

2. A a1;

3. A a2;

4. public void finalize(){

5. System.out.println("A");

6. }

7. public static void main(String args[]){

8. A a1=new A();

9. A a2=new A();

10. a1.a1=new A();

11. a2.a2=new A();

12. a1.a2=new A().a1;

13. a2.a1=a1;

14. a2.a1.a2=new A();

15. a1.a1.a1=new A();

16. a1=null;

17. a2=null;

18. System.gc();

19. }

The answer is 7.

Can someone tell me how should we work out these types of questions related to GC?

This is a question from Devaka's final exam.

How many objects are eligible for GC after line 17?

1. class A{

2. A a1;

3. A a2;

4. public void finalize(){

5. System.out.println("A");

6. }

7. public static void main(String args[]){

8. A a1=new A();

9. A a2=new A();

10. a1.a1=new A();

11. a2.a2=new A();

12. a1.a2=new A().a1;

13. a2.a1=a1;

14. a2.a1.a2=new A();

15. a1.a1.a1=new A();

16. a1=null;

17. a2=null;

18. System.gc();

19. }

The answer is 7.

Can someone tell me how should we work out these types of questions related to GC?

15 years ago

Thank you all for your replies.My confusion is now clear.

Thanks,

Aditi.

Thanks,

Aditi.

15 years ago

Thanks for the reply.

I had the understanding that the post-increment/decrement operators are evaluated only after the complete expression is evaluated and the value is returned.

Can someone please confirm this?

Thanks,

Aditi.

I had the understanding that the post-increment/decrement operators are evaluated only after the complete expression is evaluated and the value is returned.

Can someone please confirm this?

Thanks,

Aditi.

15 years ago

Sorry,the two lines are as follows:-

int x = 45;

x = x++ + x--;

int x = 45;

x = x++ + x--;

15 years ago

Hi All,

This is a question from practice exam - 3 of Devaka's Examlabs.

These are only the first 2 lines.

int x = 90;

x = x++ + x--;

This line produces the output as 91 [value of x].

As per my understanding,the vakue of x should be [45+45 = 90] and then the post-increment operators should be evaluated.

Can anyone explain how the value of x evaluates to be 91 here?

Thanks,

Aditi.

This is a question from practice exam - 3 of Devaka's Examlabs.

These are only the first 2 lines.

int x = 90;

x = x++ + x--;

This line produces the output as 91 [value of x].

As per my understanding,the vakue of x should be [45+45 = 90] and then the post-increment operators should be evaluated.

Can anyone explain how the value of x evaluates to be 91 here?

Thanks,

Aditi.

15 years ago

Thanks for the reply.

I will be careful about the forum next time.

Thanks,

Aditi.

I will be careful about the forum next time.

Thanks,

Aditi.

15 years ago

Hi All,

Thanks a lot for the clarification.

Thanks,

Aditi.

Thanks a lot for the clarification.

Thanks,

Aditi.

15 years ago

Yes,i will definitely study the Formatter documentation.

15 years ago

Hi Ruben,

Thanks a lot for the clarification!

Thanks,

Aditi.

Thanks a lot for the clarification!

Thanks,

Aditi.

15 years ago

Hi All,

I had posted this question in the wrong forum previously.

I am preparing for SCJP 1.5.This question is related to String formatting and is from Devaka's Practice exam -2.

System.out.printf("45%2$b%3$+04d",978,654,321,111);

Can someone please explain how to solve this question?

The answer given is "45true+321".

Thanks,

Aditi.

I had posted this question in the wrong forum previously.

I am preparing for SCJP 1.5.This question is related to String formatting and is from Devaka's Practice exam -2.

System.out.printf("45%2$b%3$+04d",978,654,321,111);

Can someone please explain how to solve this question?

The answer given is "45true+321".

Thanks,

Aditi.

15 years ago