Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!

Jae Lim

Greenhorn
+ Follow
since Feb 20, 2009
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 Jae Lim

Andrew Fitzpatrick wrote:Hi, I just got exactly the same problem and managed to fix it.

The problem is classpath related and to do with the order of jar and class files. To solve right click on the project in Eclipse and select properties, click the Order and Export tab. Now use the buttons on the right hand side to move the java runtime up so that it appears before all library jar files, ensure your project files still precede this library though.

A refresh on the project should see it rebuilt without issue.



Thanks for posting your solution Andrew! I had the same problem and your solution worked like a charm.
10 years ago
Hello ranchers!
I finally cleared SCJP6 today. I read K&B, did Whizlabs SCJP6.0, examlab, and inquisition. I found these great tools at Javaranch.com and would like to personally thank all for replying my questions with through details. I wouldn't have passed the exam without support of you guys. Cheers!
13 years ago

Ruben Soto wrote:Hi Rod,

Welcome to Javaranch!


I am not sure about the answer because of the pool issue. At least 2 objects (the 2 A objects,) and at most 4 objects (including the Integer and Double, which are shared between both A instances due to the fact that they are pool objects.) Perhaps someone has a more authoritative answer, although I have the feeling this would be implementation dependent, and you wouldn't find this question in the exam. But I would like to hear the official word on that too.



Hello Rod. I took my first SCJP6 exam about 2 weeks ago and this type of question was actually on the exam. That was the reason I posted this question. Thanks for the opinions everyone. Now based on the understanding that the wrapper objects get created in the pool, is it safe to assume that gc doesn't run on those pools because as far as I'm concerned, gc only runs on memory (heap)
Hello ranchers!
I have some doubt about garbage collections. Does JVM garbage collect the objects instantiated only with keyword new? If I have the code like the below, how many objects will be eligible for gc?



Also, can someone please explain me what kind of back-end work compiler does when I do the following?


Does aInt become a variable in the heap somehow because compiler changes to Integer aInt = new Integer(5); on the backend? whereas



will create a variable on the stack? Is my intuition correct?

You can make the variable static final and declare it inside of the block
Hello ranchers.
I took SCJP exam and missed my certification by a couple of questions
I scored 37% on concurrency section. I completely read all the material on K&B, gained basic understanding of thread and synchronization, took some examlab. Is there a very comprehensive tutorial online that I can actually gain some hands-on experience on this section or any existing discuss forums about this?
Hello Ranchers!
Can someone please explain me how compiler is always happy with interface casting? Please look at the code below.
Any help is appreciated..!

Henry Wong wrote:

Why "super" keyword is not accepted whereas "extends" keyword is expected?


Well, the short answer is ... super is just not allowed there.
Henry



Just like Hong said, any declaration in the top class level, generics doesn't allow you to have super keyword (i.e. <? super X>).
If you think about the reason why sun added generics into Java 1.5+ is to guarantee compile time type-safety for collections class.
Now, let's think about what happens if compiler allowed above declaration, if you think about it carefully, it violates the type-safety because the
compiler wouldn't be able to know which super class that you are referring to in the compiler time. Consider the behavior of you code if you design a class such way that makes various use of superclass of X. What kind of clue are you providing to the compiler about the superclass of X? None.

In contrast, if you use wildcard (i.e. <? extends X>), the compiler is happy because the compiler knows that type-safety occurs anything that passes IS-A test of X. Again, compiler only looks at the reference type for type-safety. You can only use <? super X> on methods and variables. Hope this helps.

-LuxuryMaster
Hello All,
I am going over mock up exams and having hard time understanding crazy generic on method signatures. This is one of the problem from the mock up exam. I am trying to understand why each each of the following method declarations are right/wrong. I am also curious what would be the best strategies to solve this type of problem in prompt manner. Is drawing the UML diagram a way to go? I can't possibly imagine spending like 10-20 on this problem I looked at the explanation but it wasn't all covered for all choices. If any of you can help me understand this better or possibly suggest any external resources, I will sincerely appreciate it.

Given the following class declaration:

abstract class A<K extends Number>{
// Insert Here
}

Which are the valid method declarations, for the above class?

A) public abstract <K> K useMe(Object k);

B) public abstract K<K> useMe(Object k);

C) public abstract <K> A<? extends Number> useMe(A<? super K> k);

D) public abstract <K> A<? super Number> useMe(A<? extends K> k);

E) public abstract <V extends K> A<V> useMe(A<V> k);

F) public abstract <V extends K> A<V> useMe(A<V> k);

G) public abstract <V super K> A<V> useMe(A<V> k);

H) public abstract <V extends Character> A<? super V> useMe(A<K> k);

I) public abstract <V super Character> A<? super V> useMe(A<K> k);

Also, if you have a method signature like the following:
public <T> Pair<T,T> twice (T value)
{

}

Documentation says that you can add the parameters can be added like the following:
Pair<String, String> pair = this.<String>twice("Hello");

I know <T> on the method above defines return type. Can someone please explain me this funky syntax? What does <T> do when placed in front of the method invokation?

this.<String>twice("Hello")

Cheers,