ansuman mohapatra

+ Follow
since Mar 04, 2008
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 ansuman mohapatra

Originally posted by Sumit Bisht:
Congratulations !

Thanks everyone...
13 years ago
Hello ppl....I have cleared SCJP.........marks nt that gud though...couldhav been came 63%...Cuz I faltered at the collections and currency section..But more importantly I have cleared it...

Thanks every1 here for your kind help and support...I really appreciate your effort...

Keep up the efforts to guide the beginners...
13 years ago
thanks a lot..i got it..

Originally posted by Henry Wong:

It's not. The Short object is still in the cache (for autoboxing). There is an errata for this question, due to this reason.


The answer is given as

"Only one CardBoard object (c1) is eligible, but it has an associated Short
wrapper object that is also eligible."

Originally posted by Jesper Young:

You don't know the name of the book? Don't you have the book anymore? Can you give us the link to where you found that book?

Yea i got it ...its from the SCJP Sun Certified Programmer for Java 5 Study Guide(Exam 310-055)

class Mixer {
Mixer() { }
Mixer(Mixer m) { m1 = m; }
Mixer m1;
public static void main(String[] args) {
Mixer m2 = new Mixer();
Mixer m3 = new Mixer(m2);
Mixer m4 = m3.m1; \\ line 1
Mixer m5 = m2.m1; \\ line 2
void go() { System.out.print("hi "); }

What is the result?
A. hi
B. hi hi
C. hi hi hi
D. Compilation fails
E. hi, followed by an exception
F. hi hi, followed by an exception

The answer given as F.

But can any1 explain what is happening at line 1 and line2. I mean what is the result if two objects are joined by a dot operator ?

and I am sorry but I got this question from a online book and I donno the name of this book.
class CardBoard {
Short story = 5;
CardBoard go(CardBoard cb) {
cb = null;
return cb;
public static void main(String[] args) {
CardBoard c1 = new CardBoard();
CardBoard c2 = new CardBoard();
CardBoard c3 = c1.go(c2);
c1 = null;
// do Stuff
} }

When // doStuff is reached, how many objects are eligible for GC?

A. 0
B. 1
C. 2
D. Compilation fails.
E. It is not possible to know.
F. An exception is thrown at runtime.

answer given as C. Short wrapper along with c1 object. But i doubt why c2 and c3 arent garbage collected ? Is it because we are passing object reference to the method so it cant be changed further ?
hey thanks 4 writin in...

but the doubt I have is in static methods overriding is not allowed, rather they allow method redifinition !!...That I didnt understand.

If method redefining refers to overloading or overriding then whats the difference of "Static Methods can't be overriden but can be redefined".

I want the difference between method redefinition and method overriding. Can som1 please explain with an example..
ok but why it doesnt start from index 0 ?
even I m confused. Can any one clarify ?

and what does for(int i:a) does ??

I am completely lost on the following question

1. public class Test {
2. public static void main(String[] args) {
3. boolean b = false;
4. String s = (b=!b)?(b=!b)?"Hello":"hello" b=!b)?"world":"World";
5. System.out.println(s);
6. }
7. }

answer is hello...

i don understand how come hello is coming although it will be coming as

String s = true ? false? "Hello":"hello" so true or false should yield true rite...then "Hello" should come

and about the 2nd part im not able to get it how its operating.

please clarify
The answer should be A since in method overriding the return types are bound to be same. Here its not same as in base class its of Object type and in derived class its of type String. Both should be either of String or Object. Or else it shows compilation error.

Hope that helps.

Originally posted by sridhar row:
I'm not sure about the order of the static here for example if i added a print statement as shown below i get a compiler error: illegal forward reference
static{ x=5;System.out.println(x);} //line 1
1 error

public class Static
static{ x=5;System.out.println(x);} //line 1
static int x = 0; // line 2

public static void main(String args[]){

so in the first static, assignment x = 5 is not happening??

No you have made a mistake at line no 1. You assigning x a value of 5 without declaring it as of which datatype. you should first declare it then initialize it. Otherwise compiler will complain.