Super class for all the classes in java
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
this is an interview question .
I SAY Object is the super class for java Language ...
then he asked whether object class will extend ??
i say Yes it will implectly extend ...
then he whether each and every class will extend object
i say yes ...
then he asked multiple inheritance is possible in java ...
i say no ...
then how will say object class will extend in each and every class....
hai friends if there is any solution tell mem
by
dhana
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
When you create a subclass like,
class child extends parent this means child is not the direct subclass of class Object, "child" is the sub class of "parent" and "parent" is a subclass of "Object" .. So this means that child is also an "Object" and it doesn't means that it's multiple inheritance it's only single inheritance.
If you are C++ programmer you can say
class child : public parent1,public parent2 ( i'm sorry if the above C++ syntax is wrong ). This piece of code says that child has all the non private members of parent1 & parent2 directly inherited this is multiple inheritance.
PS: Please check your display name before a bartender catches you!!
Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
public class java.lang.Object then what do you mean by these lines ?
then he asked whether object class will extend ??
i say Yes it will implectly extend ...
Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
am asking .. there is one class
class test
{
public static void main(String arg[])
{
System.out.println("whether this class will extends public class java.lang.Object");
}
}
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Execute this piece of code.
You can see true in the console.
[ March 21, 2005: Message edited by: Srinivasa Raghavan ]
Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
am i right ...
tell me "srini"
by
dhana
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
1.
class A extends Object {...} // Object is the direct superclass
2.
class A {...} // Object is still the direct superclass
3.
class X {...}
class A extends X {...} // Object is an indirect superclass
Every class's constructors chain up to eventually call the Object no-arg constructor and every class inherits Object's methods like equals(), finalize(), and hashcode().
Mike Gershman
SCJP 1.4, SCWCD in process
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
if any tell me ...
by
dhana
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
What do you mean by "implicit and explicit class" ?
Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
by
dhana
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Java does support multiple inheritance, right. But how ? that is through
implimentation of interfaces. Unlike c++, you can't do the following in java.
class Sub extends Super,Object{};
But implicitely, every class created in java extends Object.
that why you inherit some methods like wait(), toString ....
from class Object. eg
class Tricky{} // implicitly = the compiler sees class Tricky extends Object
class BeNice extends Tricky {}
// what you have is what you typed, there isn't a direct call to Object
// by BeNice class but it extends Object through inheritance.
Wao , hope it helps
SCJA(Beta) SCJP 1.4 SCWCD 1.4 SCBCD 1.3 SCBCD 5.0 beta <br />The more practice we get, the better we are at the exams and in life in general. Pls join me at My DEN.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
All classes have one, and only one, superclass, with one exception.
The exception is both cases is for java.lang.Object itself.
Tony Morris
Java Q&A (FAQ, Trivia)
| You'll never get away with this you overconfident blob! The most you will ever get is this tiny ad: The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |









