• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

some doubts

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have some doubts regarding SCJP exam.

Can static members be overriden?

Can interface have constructors implemented?
 
Ranch Hand
Posts: 558
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Can static members be overriden?



A big No.

But they can be hidden in extending class by having the same static signature.

Can interface have constructors implemented?


I guess here like this:
1.Constructors are used to initialize the state.
2.But interface has all "static final" variables.

Then I would like to what we are gonna write in the constructor of interface ?
 
Ranch Hand
Posts: 694
Mac OS X Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Can interface have constructors implemented?



Every class that can be instantiated must have a constructor at every level. If you don't explicitly define a constructor, a constructor will be automatically defined by the compiler that takes no parameters and merely calls the super constructor.

But interfaces cannot be created so interfaces have no constructors.

Interfaces themselves are not created, but classes that implement them can be created. You can also declare object reference variables as an interface, but the actual object being referenced is really a class that implements that interface -- not an interface.

Kaydell
[ August 11, 2007: Message edited by: Kaydell Leavitt ]
 
Srinivasan thoyyeti
Ranch Hand
Posts: 558
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kaydell Leavitt,

I agree that having constructors in Interface is useless.


But you better know this...

Abstract classes can't be instantiated.
but they can have constructors.

That constructor will initialize the state of Abstract class when extending classes constructors calls it.
 
Kaydell Leavitt
Ranch Hand
Posts: 694
Mac OS X Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

But you better know this...



Please excuse me if I offended you. I didn't mean to if I did.

Kaydell
 
Srinivasan thoyyeti
Ranch Hand
Posts: 558
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kaydell Leavitt,

I thought you may miss Abstract class issue seeing your explantion given.
Just for you.
 
Kaydell Leavitt
Ranch Hand
Posts: 694
Mac OS X Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK. Great.



Kaydell
 
If you send is by car it's a shipment, but if by ship it's cargo. This tiny ad told me:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic