• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 202
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

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