Meaningless Drivel is fun!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes mock exam Jargon(sarga) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "mock exam Jargon(sarga)" Watch "mock exam Jargon(sarga)" New topic
Author

mock exam Jargon(sarga)

Makarand Akdar
Greenhorn

Joined: Feb 03, 2001
Posts: 3
Hi friends,
public class Child extends Base {

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();
}
}
Select most appropriate answer.

a) Child.test()
Child.test()
b) Compilation Error: No default constructor ( constructor matching Base())
found in class Base.
c) Runtime Error: No default constructor ( constructor matching Base())
found in class Base.
d) Compilation Error: Cannot call this() from a constructor.
The Answer to this question in given as ...a)
Why does Child.test() print twice ?
-Thanks
Priya Kannan
Ranch Hand

Joined: Jan 19, 2001
Posts: 72
Hey, where's the base class man?
Kalpesh Pandya
Greenhorn

Joined: Oct 07, 2000
Posts: 14
Originally posted by Makarand Akdar:
Hi friends,
public class Child extends Base {

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();
}
}
Select most appropriate answer.

a) Child.test()
Child.test()
b) Compilation Error: No default constructor ( constructor matching Base())
found in class Base.
c) Runtime Error: No default constructor ( constructor matching Base())
found in class Base.
d) Compilation Error: Cannot call this() from a constructor.
The Answer to this question in given as ...a)
Why does Child.test() print twice ?
-Thanks

test() is called twice.
1. Child(int i) { test (); }
2. new Child(10.8f).test();
Shailendra Guggali
Ranch Hand

Joined: Feb 01, 2001
Posts: 86
priya - in this code there is no ref to the superclass(base)
so can we assume that the int constructor is making a call (super) to the superclass and that the superclass has to have a int constructor
OR
that the superclass has a no args constructor , hence there is no problem of super
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: mock exam Jargon(sarga)