Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in BI by (6.5k points)
recategorized by
I know that interfaces have method definitions but can they have member variables as well?

1 Answer

0 votes
by (11.3k points)

Yes, Interfaces CAN contain member variables. But these variables have to be implicitly (without any keyword definition) final, public and static. This means that within interfaces, one can only declare constants. You cannot declare instance variables using interfaces.   

Interfaces are critical to certain aspects of JAVA programming. If you're looking to learn java from scratch, consider using complex concepts such as interfaces from the ground up for basic code problems. 

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

1.2k questions

2.7k answers

501 comments

693 users

Browse Categories

...