aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Anonmyous constructors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Anonmyous constructors" Watch "Anonmyous constructors" New topic
Author

Anonmyous constructors

sanjana narayanan
Ranch Hand

Joined: Nov 25, 2003
Posts: 142
Hi,
I know that the constructors for anonmyous class is provided implicitly.
My question is
when these constructors take parameters, how are these parameters related to the enclosing /super class. Pl explain it with some code samples.
-Sanajan
Shahid Mithani
Greenhorn

Joined: Dec 04, 2003
Posts: 8
When you use default constructor to create the anonymous class, you basically call the default (no param) constructor of the overridden class.
You can also create the anonymous class by calling the overloaded constructor in the overridden class. You simply give the parameters in the constructor when you create the anonymous class.
For example...


Shahid Mithani
SCJP 96%
jayakrishna marada
Greenhorn

Joined: Dec 08, 2003
Posts: 1
Originally posted by sanjana narayanan:
Hi,
Depending on the number and type and ordering of the parameters it will look for the same type of constructor in the super class.
ex:
abstract class A {
A(int h , int j)
{
}
public abstract void callme();
}
class B
{
public A returnA()
{
return new A(5,6){
public void callme()
{
....
}
};
}
}
so the anonymous class calls the A(int , int) super class constructor.
Jay k


I know that the constructors for anonmyous class is provided implicitly.
My question is
when these constructors take parameters, how are these parameters related to the enclosing /super class. Pl explain it with some code samples.
-Sanajan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Anonmyous constructors