473,386 Members | 1,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

A question about interface

Hello!

I'm readaing a book about Inteface and it says the following.
"Only constant fields(public,static and final) are allowed in an interface.
The public, static and final key words may be
omitted, but alla fields are still treated as public, static and final."

Does this mean that every declaration of fields in an interface have the
following only form
public static final meaning no other decarations are allowed.

//Tony

Jul 18 '05 #1
2 2877
> Does this mean that every declaration of fields in an interface have the
following only form
public static final meaning no other decarations are allowed.


Yes, because you can never instantiate an interface. An interface is
only a contract that you agree to follow in your class. Often constants
belonging to the business logic of the interface are included as a
pseudo-enumeration.

/Casper
Jul 18 '05 #2

"Tony Johansson" <jo*****************@telia.com> wrote in message
news:mq*******************@newsb.telia.net...
Hello!

I'm readaing a book about Inteface and it says the following.
"Only constant fields(public,static and final) are allowed in an interface. The public, static and final key words may be
omitted, but alla fields are still treated as public, static and final."

Does this mean that every declaration of fields in an interface have the
following only form
public static final meaning no other decarations are allowed.

//Tony


That's right
public - can be accessed from other classes
static - belongs to the class - not to a specific instance
final - (constants - can't change )
its a good thing - not a limitation
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

51
by: Noam Raphael | last post by:
Hello, I thought about a new Python feature. Please tell me what you think about it. Say you want to write a base class with some unimplemented methods, that subclasses must implement (or...
77
by: nospam | last post by:
Reasons for a 3-tier achitecture for the WEB? (NOTE: I said, WEB, NOT WINDOWS. DON'T shoot your mouth off if you don't understand the difference.) I hear only one reason and that's to switch a...
65
by: perseus | last post by:
I think that everyone who told me that my question is irrelevant, in particular Mr. David White, is being absolutely ridiculous. Obviously, most of you up here behave like the owners of the C++...
1
by: Tony Johansson | last post by:
Hello! I'm reading about design pattern adaptor in the GOF book and there is something that sounds strange. When you use the adaptor design pattern you have these participants. *Target -...
0
by: Tony Johansson | last post by:
Hello! I'm reading about design pattern adaptor in the GOF book and there is something that sounds strange. The text below each participant is the book explanation for each participant. I...
9
by: phl | last post by:
hi, I am kind of confused aobut interfaces and abstract classes. In short as I understand it, an interface is like a contract between the class and the interface, so that certain funtions must...
12
by: SStory | last post by:
3rd time trying to post this but never see it in the list: =================================== In VB.NET, am doing the following with my MDI app.. Please advise if I am going about this wrong...
4
by: Rulin Hong | last post by:
According to OO, interface is just a bunch of definitions, no implementation at all. It's also true when we write our own code in .NET. But I find every interface provided by .NET has specific...
4
by: David Zha0 | last post by:
Hi, "when we call a virtual method, the runtime will check the instance who called the method and then choose the suitable override method, this may causes the performance drop down", is this...
9
by: Tony | last post by:
Hello! The keword abstract and sealed are not allowed in interfaces. I can understand that abstract is not allowed because an interface is completely abstract and contains no implementation. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.