Java Programming - Language Fundamentals - Discussion
Discussion Forum : Language Fundamentals - General Questions (Q.No. 7)
7.
public interface Foo
{
int k = 4; /* Line 3 */
}
Which three piece of codes are equivalent to line 3?
- final int k = 4;
- public int k = 4;
- static int k = 4;
- abstract int k = 4;
- volatile int k = 4;
- protected int k = 4;
Answer: Option
Explanation:
(1), (2) and (3) are correct. Interfaces can have constants, which are always implicitly public, static, and final. Interface constant declarations of public, static, and final are optional in any combination.
Discussion:
31 comments Page 3 of 4.
Chandini said:
1 decade ago
In 1.8 version Interfaces support default implementations also.
Vishal said:
1 decade ago
Why public, static, final is only used in interface method?
Archana said:
1 decade ago
Answer is A because interface contain an abstract method.
Aman Kumar said:
4 years ago
Why not be volatile and protected? Please explain.
(1)
Reshma Wadhavane said:
9 years ago
Interface contains only static and final variable.
Mohd Shahid Arafat said:
1 decade ago
Interface has provide 100% of abstraction method.
Md Mahbubur Rahman said:
10 years ago
Interface are public, static & final.
Meena said:
1 decade ago
Interface contain only abstract methods.
Viper5073 said:
1 decade ago
Interface contain only abstract methods.
Ann said:
1 decade ago
What is static in java ?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers