This week's giveaway is in the Spring forum.
We're giving away four copies of Microservices Testing (Live Project) and have Chris Love & Andres Sacco on-line!
See this thread for details.
Win a copy of Microservices Testing (Live Project) this week in the Spring forum!

Krishna

Greenhorn
+ Follow
since Oct 31, 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 Krishna

Hi Kambiz,

An interface may or may not have any methods in it.

If at all it has any methods, they are public abstract by default and any non-abstract class implementing it should provide the method implementation for all the methods available.
Hi Varalakshmi,

A non-static class member (a variable or a method) needs an outer wrapper on which it can be called or accessed. The wrapper is nothing but an instance of the class, an object. Every object has its own set of the non-static members and handles it.

On the contrary, a static method or variable is run by the class itself(not an object). So, to access a static method, you can use either the method name only or the syntax Classname.Method()

I think that clears your doubt...

Hi,

Actually all the objects will be on a heap. Object references are not objects at all. So neither of c1, c2, c3 and cb will be on the heap. They all will be on the stack only.

Now, c1 will be pointing to a new object object1 of type Cardboard and c2 will be pointing to a new object object2 of type Cardboard. Remember that these are only references. So when we pass c2 as an argument, we are actually assigning a new reference to the already available object (pointed to by c2). So cb also now points to object2. Within the function, this object reference cb is set to null and the null object is returned. This is assigned to c3.

Note that the connection of cb with object2 has been cut, but still object2 has a reference c2 pointing to it.

Now c1 is set to null. So, object1 is eligible now for garbage collection. Totally, the references c1, cb and c3 point to no objects. Object1 has no reference now. Object2 has c2 pointing to it.

So, only one object is eligible for garbage collection.

Get back in case of any more doubts...