Am i right till here ?
2) I didnt find any constructor in Object class like that while referring the api . so since the Object class doesnt contain any constructor .it should be a compiler error i suppose !
But why is the compiler ignoring it .
SCJP 6
SCJP5 and SCWCD1.5
Think Twice Act Wise...
srikanth mycherla wrote:2) I didnt find any constructor in Object class like that while referring the api .
SCJP 6
SCJP 6
SCJP5 and SCWCD1.5
Think Twice Act Wise...
Ganeshkumar cheekati wrote:if the compiler can add default constructor then it can have public modifier because Object class is havng public modifier..
but here in api he doesnt mention any modifier like public so that we can treat that it is having default modifer
SCJP 6
srikanth mycherla wrote:sorry punit .there is a default constructor in object class.
punit if my class is public (obviously since ill have main method in that class) how come the line
public super() (added by the compiler ) can invoke default constructor of object class ?
confused!!!
SCJP 6
srikanth mycherla wrote:i agree with you .but will the compiler add public constructor if the classs is default ? In the book it did like this .Is that right?
SCJP 6
SCJP 6
Why to worry about things in which we dont have control, Why to worry about things in which we have control ! !
SCJP5 and SCWCD1.5
Think Twice Act Wise...
Ganeshkumar cheekati wrote:SO finally there is an default constructor is available in Object class with public access modifier
SCJP 6
Punit Singh wrote:
Ya it is added by compiler.
SCJP5 and SCWCD1.5
Think Twice Act Wise...
Punit Singh wrote:Ya it is added by compiler.
Pawel Nowacki wrote:
There is public Object() constructor, i think.
http://java.sun.com/j2se/1.3/docs/api/java/lang/Object.html
Ganeshkumar cheekati wrote:
Punit Singh wrote:
Ya it is added by compiler.
Mr.punit
will it added by compiler at compile time?
or
Is it available in Object class?
If there is no one available then compiler can add def constructor but api saying that there is an def constructor in Object class.
SCJP 6
Punit Singh wrote:
Why do not you open source code of Object class and see there ?
SCJP5 and SCWCD1.5
Think Twice Act Wise...
Pawel Nowacki wrote:
There is public Object() constructor, i think.
http://java.sun.com/j2se/1.3/docs/api/java/lang/Object.html
Ya it is added by compiler.
Ganeshkumar cheekati wrote:
Punit Singh wrote:
Why do not you open source code of Object class and see there ?
can you send me the link?
i just saying based on api...
SCJP 6
SCJP5 and SCWCD1.5
Think Twice Act Wise...
Ganeshkumar cheekati wrote:yes punit you are right .
compiler can add default constructor with public modifier..
but they have mentioned as
public Object()(Constructor summary) in api so that i thought it is available source code.
SCJP 6
SCJP5 and SCWCD1.5
Think Twice Act Wise...
srikanth mycherla wrote:default is not added by the compiler even our class is default .it adds public constructor in order to work across packages
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Object
public Object()
SCJP 6
srikanth mycherla wrote:ya but ankit is saying there is no constructor in object class ! but i can see constructor in api..confused!
SCJP 6
Punit Singh wrote:
srikanth mycherla wrote:ya but ankit is saying there is no constructor in object class ! but i can see constructor in api..confused!
I told you na, compiler is adding public Object(){}, in source code there is no constructor, as I had said in earlier replies. Read all replies once again, you will get everything.
SCJP 6
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
knowledge is the difference between drudgery and strategic action -- tiny ad
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|