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

Posted on 2005-04-27
Last Modified: 2010-03-31
public, private, static, protected, default :o), and whatever are there in java...
Question by:letsbedecent
    LVL 15

    Expert Comment

    methods inside an interface are ALWAYS going to be public.
    LVL 15

    Accepted Solution

    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
    LVL 15

    Expert Comment

    putting something else (static, private protected) to a method should yeild a compilcation error.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Suggested Solutions

    By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
    Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
    Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
    Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now