Amit Mahajan

+ Follow
since Jul 13, 2007
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 Amit Mahajan

Yes,that might be true as they had these special dicounted vouchers till the August end.
Hi Arunam

From April to June there was a special offer.
For floating point number like float ,double etc result type is double
For integer type numbers like int , long etc the result type is int

If we have a float and a long the result should be double because one number is floating type.

Amit Mahajan
But there is an exception to this rule..
Suppose you write code in finalize() that makes the object ineligible for GC.. In that case the next time VM tries to GC the object it will skip the finalize() method..
Go for 1.5
But more important is to know difference b/w the 1.4 and 1.5.
What are the new features in 1.5 (like generics , covariant return types , enums , etc)

Amit Mahajan
Hi Manfred

The following must be true:

bb instanceOf A; //true
ab instanceOf A; //true


Thanks guys for clearing the confusion..
To summarize

class A{}
class B extends A{}
class C{}
A aa = new A();
B bb = new B();
A ab = new B();
C cc = new C{};

aa instanceOf A; //true
aa instanceOf B; //false
bb instanceOf A; //false
bb instanceof B; //true
ab instanceOf B; //true
ab instanceOf A; //false
cc instanceOf A; //compilation error (not in the class hierarchy)
cc instanceOf B; //compilation error (not in the class hierarchy)

Correct me if i am wrong.
If you been a C user remember that difference betweent the two(Java and C) in relation to GC . In C we don't have GC done implicitly, but we need to GC explicitly. In java it's done by the system , only catch being you have very less or no control over it.
Hi Praneeth

I also faced the same problem.
Programmatically thrown exceptions are the one thrown explicitly from your code.
It can be both checked or unchecked as said by Murali.

Hey it's simple

128 in bits is 1000 0000

A byte has it's 8th bit as the sign bit.
Hence 1000 0000 , a byte will interpret as negative number and
the no. will be calculated using 2's complement.

Which means 1000 0000 --> 0111 1111
+ 1
1000 0000

O/P -128
Hey Congrats..

Amit Mahajan
SCJP 1.4
start() method creates a new stack on which your thread executes..
Hence answer is start() method , but actuall excecution starts when run() is called.
Yes it will be eligible for GC.

Amit Mahajan
SCJP 1.4
Hi Pratibha

A lot depends on your current Java experience and knowledge.
1 month is sufficient if you have few years of experience behind you.

Please also see related threads where people have asked the same question.

Amit Mahajan

SCJP 1.4
Observe following things in the code:

class A extends Thread {
public A(Runnable r) {

public void run() {

1. The run() method has been overriden.

2. When you are doing

Thread e = new A(new B()); //Line 3

the e reference is pointing to A's object and calls the run() method in A.
That's why you see output as A.

If you had done
Thread e = new Thread(new B());

then it would have called the original run() and the result would have been as you expected.

Correct me if I am wrong.