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
posted
0
Hey, where's the base class man?
Kalpesh Pandya
Greenhorn
Joined: Oct 07, 2000
Posts: 14
posted
0
Originally posted by Makarand Akdar: Hi friends, public class Child extends Base {
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
posted
0
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