File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Interface Fields

 
Naresh Chaurasia
Ranch Hand
Posts: 361
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the reason of having fields as static and final in interfaces?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
because interface can not have implementation
 
Mo Jay
Ranch Hand
Posts: 83
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SCJP 1.4

Again Naresh Chaurasia , you are supposedly already certified therefore you shouldn't be asking basic questions like these that were part of your preparation for the SCJP exam in the first place. I Also noticed in another thread that you asked another basic question regarding checked/unchecked exception, these make me wonder how did you become SCJP and what did you use as a study material if any.
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4116
195
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mo Jay wrote:
SCJP 1.4

Again Naresh Chaurasia , you are supposedly already certified therefore you shouldn't be asking basic questions like these that were part of your preparation for the SCJP exam in the first place.


Cooldown I think he need to upgrade his certification to the latest version, and might need to focus on some topics like this. Anyway, anyone can ask any SCJP-related question here.

Devaka.
 
Muhammad Khojaye
Ranch Hand
Posts: 449
IntelliJ IDE Java Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Naresh Chaurasia wrote:What is the reason of having fields as static and final in interfaces?



Also remember, interface serves as a type which means the class that implement an interface say something about what a client can do with instances of the class, which become inappropriate when you use interface only for defining constants.

 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Muhammad Ali Khojaye wrote:
interface serves as a type which means the class that implement an interface say something about what a client can do with instances of the class, which become inappropriate when you use interface only for defining constants.


Exactly . use final class to define the constants.giving a private constructor makes sense
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic