File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes java programmer certificate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "java programmer certificate" Watch "java programmer certificate" New topic
Author

java programmer certificate

Kameshwar Prasad
Greenhorn

Joined: Dec 04, 2007
Posts: 12
the fallowing code is from Jargon test (http://www.sarga.com)when this progra is being compiled giving

No constructor matching Base() found in class Base.
Child(int i) { test (); }
as there is no call for default base constructor in child class
why this error ?
<pre>

class Base
{
Base(int i) { test(); }
// Base(){}
void test() {
System.out.println("Base.test()");
}

}

public class Child extends Base {


byte b = 1 ;
Child(int i) { test (); }
Child(float f) { this ((int)f); }
void test() {
System.out.println("Child.test()");
}

static public void main(String[] a) {
new Child(10.8f).test();
}
}

</pre>

[This message has been edited by maha anna (edited April 23, 2000).]
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944

All base class constructors call the super class
constructor first. It is always considered a good
programming habit if you explicitly call (IMO).
If you donot explicitly call the super class
constructor explicitly, then the JDK will make the
call on your behalf. Since in this example you din't
make the call explicitly, JDK calls the default super
class constructor which takes no arguments. Now, in the
super class you did provide a constructor explicitly.
Hence the default constructor is not avail for this super
class. Hence the ERROR.
Hope this helps.
Regds.
- satya
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java programmer certificate
 
Similar Threads
mock exam Jargon(sarga)
super in constructors
Constructor
Confused help me!!
Jargon mock exam