Results 1 to 6 of 6
- 04-08-2011, 10:57 AM #1
Member
- Join Date
- Apr 2011
- Posts
- 2
- Rep Power
- 0
- 04-08-2011, 11:11 AM #2
Senior Member
- Join Date
- Dec 2008
- Location
- Kolkata
- Posts
- 280
- Rep Power
- 5
Probably JLS says that, and the following code proves the fact.
Java Code:class ParentTest{ public static void main(String arg[]){ ParentTest t=new ParentTest(); if(t instanceof Object){ System.out.println("Point is true"); } } }Swastik
- 04-08-2011, 11:37 AM #3
Senior Member
- Join Date
- Dec 2008
- Location
- Kolkata
- Posts
- 280
- Rep Power
- 5
Another way to prove the fact
Java Code:class ParentTest{ private void showParentClass(){ System.out.println("Parent class name is "+getClass().getSuperclass().getName()); } public static void main(String arg[]){ ParentTest t=new ParentTest(); t.showParentClass(); }Swastik
- 04-08-2011, 12:22 PM #4
Member
- Join Date
- Apr 2011
- Posts
- 2
- Rep Power
- 0
Yes parent class of any class is Object I know. But I want to know how Object be parent class of all as we don't even extend it?
-
Because that is how Java is defined per the JLS, period (as mentioned already in the first reply to this thread).
Please see: 4.3.2 The Class Object
- 04-08-2011, 12:37 PM #6
Senior Member
- Join Date
- Dec 2008
- Location
- Kolkata
- Posts
- 280
- Rep Power
- 5
Its tough to say how, but that is what java language specification says.
Types, Values, and VariablesSwastik
Similar Threads
-
lock on ".class" object
By rajinder5 in forum Threads and SynchronizationReplies: 0Last Post: 10-11-2010, 04:38 PM -
Java, Military Format using "/" and "%" Operator!!
By sk8rsam77 in forum New To JavaReplies: 11Last Post: 02-26-2010, 03:03 AM -
How to use "Class convexHull.GrahamScan" in Java
By Mazharul in forum Java 2DReplies: 1Last Post: 04-18-2009, 05:14 AM -
MoneyOut.println("It took you (whats wrong?>",year,"<WW?) years to repay the loan")
By soc86 in forum New To JavaReplies: 2Last Post: 01-24-2009, 06:56 PM -
the dollar sign "$", prints like any other normal char in java like "a" or "*" ?
By lse123 in forum New To JavaReplies: 1Last Post: 10-20-2008, 07:35 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks