Milan Bhagwat

Greenhorn
+ Follow
since Oct 07, 2009
Merit badge: grant badges
For More
India
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 Milan Bhagwat

Amazing subject picked up by Raju, waiting to read it !!
Great to see book on certification so many professional get helped with this.
Hi Nicolai, Great to see book on Module system. Does this book also includes JDK 11 changes?  
4 years ago
Hi Geoffrey,

What are the exclusive topics focused in book "Phoenix in Action" ?

4 years ago
you can use contains() method provided by Set to check whther perticular object present in given Set(returns true) or not(returns false).
14 years ago
Hi Will, i am interested to explore in the field of java reporting using xslt/xml and also given hand on XSL-FO. is the java reporting is also using xsl-fo?
Welcome Will, i am interested to explore in the field of java reporting using xslt/xml and also given hand on XSL-FO. is the java reporting is also using xsl-fo?
Hi Sreenivasa,

here the trick is to see the scopes of different block variables.

main() ----- list ---> ArrayList()

after first call to modifyObject (list);


modifyObject(ArrayList listObj) -- varible listObj ----> arrayList object with value {1} // stackTrace
main() -------------- varible list ------------------------>
so both varbles list and listObj refers to same obj with value 1.
now the local variable listObj=null, but the list local varbiable in main method still refers to obj with value 1.

now, after second call from finally clause

again
modifyObject(ArrayList listObj) -- varible listObj ----> arrayList object with value {1,1} // stackTrace
main() -------------- varible list ------------------------>

so now the list size comes 2, not the NPE.
Hope this is clear now.
Thanks guys for fast inputs. just want to confirm my understanding....

1) As the absence of correct constructor(for constructor call whether no-arg or with arg) is deffinately leads to error condition and so compiler stops us by giving compile time error.

2) while declaring subclass, no any constructor(whether subclass's or super class's) gets the call.

means while declaring below subclass the println will not execute:

class Super{
Super(int i){ // overloaded constructor of super class
System.out.println("in Super");
}
}


class Sub extends Super{

// no constructor declared means only default constructor available inserted by compiler
}

its only get called when the object creation happens like: calling new Sub(); (ofcourse of the correct constructor will be available , as in this case we need to insert no-arg constructor in Super class).

Please confirm my understanding.

Thanks in Advance.
Thanks Ankit for detailed desription.

But still i am confused as the constructor calls happens only when we create object like:

MySuper ms1=new MySuper(); or
MySub ms2=new MySub();
so whts the problem at compile time when the constructor didnt get the call....

Thanks,
Milan
As Java guys are familiar with the compilation error while the Super class contains overloaded constructor(with arguments) and subclass doesn't call externally to overloaded super()(with argument).

But, i am unable to understand that while only declaring class and not calling the constructor(while Object creation) why the copiler doent allow?

Guys, detailed response will be appreciated.....