Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 198
  • Last Modified:

which access modifiers cant be used for methods in an interface ??

public, private, static, protected, default :o), and whatever are there in java...
0
letsbedecent
Asked:
letsbedecent
  • 3
1 Solution
 
aozarovCommented:
methods inside an interface are ALWAYS going to be public.
0
 
aozarovCommented:
No need to define it.
Also variables inside an interface are always going to be "public static final".

So you can define an interface
interface I
{
void myMethod();
String MY_CONSTANT;
}

and myMethod will be treated as public
and MY_CONSTANT will be treated as public final static
0
 
aozarovCommented:
putting something else (static, private protected) to a method should yeild a compilcation error.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now