Back

Explore Courses Blog Tutorials Interview Questions

Explore Tech Questions and Answers

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

0 votes
2 views
by (6.5k points)
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
asked Nov 12, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...