Javardhan:
Javardhan:
With Regards<br />Arul
Originally posted by KJ Reddy:
All constructors and methods are getting inherited in sub classes.
Originally posted by Aleksander Zielinski:
Subclass does not inherit superclass' constructor.
Javardhan:
Originally posted by Ja vardhan:
Thanks for your replies.
One more doubt regarding constructors:
From K&B book I read
-----------------------------------------------------------------------
If you do type your own constructor (as opposed to relying on compiler generated default constructor), and you do not type in the call to super(), the compiler will insert a no-arg call to super() for you.
-----------------------------------------------------------------------
Whats the case if I dont have no-arg constructor in the super class??
Why it shouldn't throw error when compiler is insertign call to super class's no-arg constructor but actually I dont have such constructor?
Thanks.
Phil
Originally posted by Higgledy Smith:
If in the super class you do define a constructor that takes args the compiler will STILL automatically generate a no-arg constructor in the super class.
Phil
Mike -- SCJP, SCWCD
One more doubt regarding constructors:
From K&B book I read
-----------------------------------------------------------------------
If you do type your own constructor (as opposed to relying on compiler generated default constructor), and you do not type in the call to super(), the compiler will insert a no-arg call to super() for you.
-----------------------------------------------------------------------
Whats the case if I dont have no-arg constructor in the super class??
Why it shouldn't throw error when compiler is insertign call to super class's no-arg constructor but actually I dont have such constructor?
Thanks.
--------------------
Javardhan:
Javardhan:
Originally posted by Durga Krishna:
I have one more doubt.....
I can have an abstract class without having any abstract methods in it.
Then what is the use with such a class declaring as abstract.?What i mean is - why compiler will not throw any exception if, we compile an abstract class having no abstract methods in that class?
SCJP 1.5
Dolphins are grey, but they dream in colour.
Originally posted by Durga Krishna:
I have one more doubt.....
I can have an abstract class without having any abstract methods in it.
Then what is the use with such a class declaring as abstract.?What i mean is - why compiler will not throw any exception if, we compile an abstract class having no abstract methods in that class?
Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Steven Elliott wrote:What is interesting is if you add the following to the main method:
System.out.println("Test classname = "+at.test.getClass().getName());
will return "Test classname = classes.AbstractTest$1" indicating that Test has been compiled as an inner class of AbstractTest...! What kind of inner class?
What is then interesting is if you test instanceof:
System.out.println("at.test instanceof Test = "+(at.test instanceof Test));
Will return "Test instanceof Test = true"
The answer is yes, you can instantiate an abstract class... more or less;)
An anonymous subtype of Test.
Flex Development | Flex Developer in India
SCJP
Visit my download page
It's a pleasure to see superheros taking such an interest in science. And this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|