Public access specifier in interface

I have a slight problem with my code below. I created a file and named it ClosedCurve.java* and wrote all code into the file.
My code below wont be compiled. unless I add an access specifier public . and I do not understand why i need to do that. I got an error that say "Cannot reduce the visibility of the inherited method from ClosedCurve"
package classs.and.objects;
public interface ClosedCurve {
    double computeArea();
class Triangle implements ClosedCurve {
    double computeArea() // I need to change to public double computeArea()
        return 0.0;
}

The default specifier within the interface (in fact the only specifier within the interface) is public. The default specifier (when none are noted) for classes is package-private which is less visible than public.
Please have a look here: [Controlling Access to Members of a Class|http://java.sun.com/docs/books/tutorial/java/javaOO/accesscontrol.html]

Similar Messages

  • Access specifiers for interface methods

    When we implement the interface ,we have to specify the implementing method access specifier to be "PUBLIC" ,but not "PROTECTED" or "PRIVATE".
    Compiler is giving an error -- attempting to assign weaker access privileges ,when we specify protected.
    what is the internal reason for this?Why we shouldnt make the access weaker in the implementing class.
    Can any one help me on this.Your help is highly appreciated.

    When we implement the interface ,we have to specify
    the implementing method access specifier to be
    "PUBLIC" ,but not "PROTECTED" or "PRIVATE".
    Compiler is giving an error -- attempting to assign
    weaker access privileges ,when we specify protected.
    what is the internal reason for this?There is absolutely no point in having a private interface method. The interface represents a visible abstraction and private methods are never visible so it is a contradiction in terms.
    An interface is intended to represent an abstraction that a user (software) uses. Protected via child/parent represents a usage that is restricted to a child from a parent. The child can already see the parent so there is no point in having an abstraction for the child. And it would probably be unwise to limit a child by such an abstraction.
    Protected via the package and interfaces is more contentious as to why it is not allowed. There are those that argue that this should be allowed so that a package can use interfaces but restrict them to the package. To me this seems like a minor point given that most interfaces will probably represent an abstraction to other packages and not within a single package. This applies specifically to default access as well.

  • DTO with attributes having public access.

    Hi
    In my application I'm using Data Trandfer Objects for trasfering data between client and server. It's only used for travfering data and as a client side buffer. Shall I keep all the attributes with public access specifiers?Is it against any concepts?
    Example:
    public class ResourceDetailsTO {
    public String resourceId;
    public String lastName;
    public String firstName;
    public String department;
    public String grade;
    Any help will be appreciated?

    >
    So my proposal would be a class with a public
    constructor, only private attributes and publich
    getter methods. Additionally, you should implement
    toString to allow easy debugging.
    That gets rather tedious when the GUI layer wants to modify a single attribute.
    The reason is, that you can easily introduce errors,
    if you make all attributes public. Just consider the
    following example:
    ResourceDetailsTO rdto = receive(); // suppose, this
    is some method, which creates a DTO
    process(rdto); // here we do something with this DTO
    // here you can not know, whether the DTO was modified
    by process!!At least in my implementations, I don't try to guess whether it was modified or not. The caller is specifically required to do something different if is modified vs if is not.
    And I not sure how this example proves your point. Creating a new object everytime doesn't tell you whether it was modified or not from the original. If you want to track modification then add a setter which sets a flag.
    Additionally, if you
    implement equals and hashCode, then your DTO could be
    a good candidate as a key in a HashMap. Why? The only reason for doing this is to cache the data. So what interface is caching the data? And what happens when the persisted object gets overwritten by another object by another source?
    However if the
    object is modifyable, then somebody could modify the
    attributes, while it is used as a key in some HashMap.Yes, if it used in a hash then modifying it will break it.
    But the vast majority will not be used in a hash.
    And when it is used in a hash it will not be used as the key.

  • Access specifier

    Hi,
    Can anybody tell me as to why we use the public access specifier in the main method as a standard.I have tried out the other access specifiers in the main method and it works fine.
    [please note i do understand the relevance of each access specifier in other contexts.]
    tubby

    It's supposed to be public because the JVM specification says so, but, yeah, you can use more restrictive access modifiers (that is to say, the compiler will permit more restrictive modifiers). Sun doesn't consider the issue an open bug, but you can read the discussion on the issue here: http://developer.java.sun.com/developer/bugParade/bugs/4252539.html

  • My java program runs fine even if i don't specify access specifier of class

    Hi,
    My java program runs fine even if i don't specify access specifier of class as public .
    Then why do they say that atleast one class should be specified as public.
    please help.

    public access specifier is the default access
    specifier
    so if you dont give the access specifier before the
    class name it is not wrong.I think that you are wrong. The default specifier is package or "package-private".
    See here:
    http://java.sun.com/docs/books/tutorial/java/javaOO/accesscontrol.html
    Message was edited by:
    petes1234

  • Trying to compare FCP with Media 100 for a Public Access studio

    Hi all,
    I am new here. I do most of the review of products for our Public Access studio. We have a couple of existing Media 100 systems and we are considering adding or upgrading our NLE capabilities. Our studio manager had a chance to look at FCP being used at our high school and she came back with a number of impressions that I wonder about and would like to vet with people who know more about FCP. So, any comments would be helpful.
    The high school media person demo’d FCP for her and let her play with it a bit. After looking at it herself, she says she would definitely say Media 100 is easier to understand/use, especially if you've never used non-linear editing before. That is fairly typical of the people doing Public Access production in our town.
    However, it looks to her like there are a lot of tools that come with FCP that Media 100 either doesn't have or are not easily found in it. For example, she feels FCP’s set up looks more complicated and confusing compared to Media 100’s, but in FCP you can have up to 99 video lines in a program, where with Media 100 we're just going back and forth between the a and b video lines. Plus you can have up to 99 Audio tracks on FCP as well, where our max at the moment is 8. Now as to when you would need 99 video or audio tracks, she is not sure, but it is definitely a capability that we don't have in Media 100.
    Titling looked easier to her on Media 100. With FCP there were a lot of filters involved and hoops to jump through, plus she couldn't do a word with each letter a different color, for example, unless she did each letter on a different track.
    The media person warned her that FCP is really large. Apparently the program itself takes up like 35 GB of space on the hard drive, and a typical 30 min. project comes in at over 100 GB! She couldn't believe it, but she was assured it’s true. Even with our longest programs, like like a School Committee meeting thqat went 3 1/2 hours, it would came in at a max of 30 GB on the Media 100. She got the impression this big difference was so because Final Cut renders everything you do, including rendering any edits you make on your footage as new files, and stores it all in a huge folder. She thinks with Media 100, you import the footage and use it as is - the only things it will render are screen freezes, transitions, and color effects. Is that sort of comparison correct (and fair), or is something being missed?
    She says in her experience that something like iMovie is the most basic as far as what you can do, then Ulead would be a step above that- the editing is basically the same, but you have a few more options. Media 100 would be next as far as ease of use and understanding of the program. FCP seemed a little confusing even to her. Comments or insights?
    G4   Mac OS X (10.4.7)  

    Welcome to the family, maybe.
    I switched from M100 about four years ago, I was never so glad to give that company the boot. A direct comparison just isn't possible but I'll try to answer some questions. There is a Media 100 forum on creativecow.net.
    she says she would definitely say Media 100 is easier to understand/use, especially if you've never used non-linear editing before.< </div>
    Yes, absolutely, M100 has always had an elegant and refined interface. However, the paradigm in FCP is not opaque. It's far more interesting, deeper, more complex. So, yes, it's a bit tougher to grasp. But don't sell your students/users short. They'll get it.
    99 tracks is marketing BS. The serious work is done with nesting. How many public access pieces need more than 5 or 10 video tracks?
    Titling in FCP depends on third party filters like Boris or tools like LiveType and Motion. The basic titling tools in FCP are lame and difficult to use, in my opinion, compared to the elegant titler in M100 (as long as you don't launch Graffiti).
    The installation includes tens of gigs of animation, movie and music loop resources that you don't need to load. The suite includes Motion, LiveType, Soundtrack Pro, DVD Studio Pro and FCP.
    If you're shooting DV, a 3-1/2 hour show is, umm, well, you look it up, DV is DV. But if you're capturing 3 hours from each of three cameras, that's a lot of DV.
    Rendering depends on lots of things. M100's native codec handles lots of realtime stuff that FCP can't unless you've got a huge Macintosh. Previewing is not a big deal at lower rez in FCP, you get used to it. .
    FCP is really scary. You can look at thousands of "I'm in way over my head, HELP!" posts here. But all those folks find they slip right into the Apple paradigm, the weirdly new workflow and start exploring the wide new world of serious editing that FCP opens up. You'll hate it for a few months because it's so dramatically different from M100. You'll love it, though.
    If you want to continue the thread, give the rest of the disaffected former M100 users a few days to post their comments. There are many of us here. Then maybe start a new thread, one question at a time.
    bogiesan

  • Problem with access specifier and static???

    I've a question. I saw a code written for Sun's Java Tutorial. The program had three class methods and all of them start like this:
    static public void methodName1{
    static public void methodName2{
    and
    static public void main(String[] args){
    My question is why the keyword static was used first? Why not access specifier? I mean what's the reason behind it? Is there any difference between them?
    Thanks in advance.
    --DM

    The order doesn't matter. The programmer thought it was a good idea for some reason. I might be tempted to do it if I had static and instance methods with the same name or something like that.
    public static void myMethod() {
    public void myMethod() {
    or
    static public void myMethod() {
    public void myMethod() {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Accessing AM Client Interface from Web Application

    Hi,
    I am trying to access some client interface methods that I developed on my application module from a backing bean on my web application and have trouble doing so.
    Some background on the problem,
    Basically when logging into our application from the front-end, we have to authenticate the user against some custom security code. Part of this code is to validate the user against the Oracle database (i.e. valid oracle db user, and password is valid password to log onto Oracle database). To do this, I developed Client Interface methods on an Application Module. When using the BC Tester in jdev 11g (the latest release), these methods work 100% and validation occurs. On our logon page, I bound these methods to the page definition file. When I then try in the backing bean to call this method, using the code from the ADF 11g Dev guide as below, the DataControl on the action is null at point 3. It does seem to find the action find. I have also tried to actually use the "setParams" method on the action, and then tried the execute(), invoke() + getResult(), and doIt() + getResult() methods, of which none seems to work. All these go past the execute/invoke/do part, but the return value on the execute, as well as the return value from the getResult calls are null.
    public String commandButton_action() {
    // Example using an action binding to get the data control
    public String commandButton_action() {
    // 1. Access the binding container
    DCBindingContainer bc = (DCBindingContainer)getBindings();
    // 2. Find a named action binding
    JUCtrlActionBinding action = (JUCtrlActionBinding)bc.findCtrlBinding("SomeActionBinding");
    // 3. Get the data control from the iterator binding (or method binding)
    DCDataControl dc = action.getDataControl();
    // 4. Access the data control's application module data provider
    ApplicationModule am = (ApplicationModule)dc.getDataProvider();
    // 5. Cast the AM to call methods on the custom client interface
    StoreServiceAM service = (StoreServiceAM)am;
    // 6. Call a method on the client interface
    service.doSomethingInteresting();
    return "SomeNavigationRule";
    Can somebody perhaps tell me what I am doing wrong, or of a better approach to resolve this problem. If any more info is needed, please let me know.
    I did think about binding the action directly to the logon button on the jsf page, but unfortunately there is additional logic/code that is currently in the backing bean that I do not want to move down into the business components, and some code like the lines below that can not be moved.
    HttpSession session = (HttpSession)externalContext.getSession(true);
    session.setAttribute(SecurityFilter.SESSION_ATTR_USER, securityDto.getUsername());
    session.setAttribute(SecurityFilter.SESSION_ATTR_SECRET, securityDto.getPassword());
    session.setAttribute(SecurityFilter.SESSION_ATTR_ROLES, securityDto.getRoles());
    return "logonSuccess";
    Will really appreciate any help.
    Tx
    Drikus

    Hi,
    I managed to find some sort of work around.
    I actually dragged and dropped the Client Interface for the custom method from the datacontrol onto my jsf page and created an additional button. I then ran the application and everything worked. Afterwards I went back to my jsf page and removed the newly added button again and removed the newly added methods from my page definition file as well. When I run the application now, the exact same code that I used previously, now seems to work. I changed it to use the findDataControl method as Frank suggested, and that also works now.
    What i can not figure out though, is what exactly the the dropping of that dataControl method and removing it again changed on my application to make it work now. Can somebody please try this and see if they can find the answer. I have done a small little sample application where I can replicate the problem exactly which I can provide the steps to if needed.
    Drikus.

  • Java inner class access specifiers

    public class MyClass1 {
    public static void main(String argv[]){ }
    /*Modifier at XX */ class MyInner {}
    What modifiers would be legal at XX in the above code?
    1) public
    2) private
    3) static
    4) friend

    Iam a newbie to javaI don't care. I still assume you have a brain and expect you to use it.
    and iam struck with this
    question, iam getting a compile time error for any
    access specifiers mentioned as options, but the
    answers given by my superior are 1,2,3, are
    correct..Then you made a typo or whatever. Make sure you eliminate the problems that are not "illegal access modifier" errors.
    What good is knowing the reply to this if you can't even write an example?

  • Access specifiers !!! ??? !!!

    In many examples I often find that members ( be they classes, interfaces, variables ) are declared "public" in a class with package access. Consider this:
    // c08.Accessible.java
    package c08;
    public class Accessible {
    String s = "Non public Member";
    public NotAccessible na = new NotAccessible();
    class NotAccessible {
    public String s = "Public Memeber of Package class";
    // Test.java
    import c08.*;
    public class Test {
    public static void main(String[] args) {
    Accessible a = new Accessible();
    System.out.println(a.na.s);
    The compiler allows me to access the object of type NotAccessible through an object of type Accessible from Test! However it denies access to the public variable s belonging to NonAccessible.
    1. Do you not see a contradiction ?
    2. Why would I want to declare a public member in a class with package access ?
    The only case where a public member declared in class with package access could possibly make sense is when inherited by a public class. Not sure though ! How do I go about it ? Does the Language Specification make an explicit reference to such a case?
    Many Thanks

    Oh I nearly forgot: One definition found in the The Language Specification is the following:
    A member (class, interface, field, or method) of a reference (class, interface, or array) type or a constructor of a class type is accessible only if the type is accessible and the member or constructor is declared to permit access: etc etc.
    Furthermore, if the object na has public access, shouldn't s be accessible through na, since s is a public member belonging to the same class as na?
    Cheers

  • Regarding Protected access specifier

    Hi ,
    I thought that indeed you could access protected data member from another package IF you are using Inheritance. It makes the data memeber in question "friendly" to the derived class. At least that is my understanding.
    You can not access protected data element directly in different packages. package test1;
    public class Test123 {
    protected int x=42;
    package test2;
    import test1.Test123;
    public class Test234 extends test1.Test123{
         public static void main(String args[]){
              Test123 ob=new Test123();
              System.out.println("x="+ob.x);
    but My question is that ..if u run this program its not compile..Compile time exception is throws saying that the field Test123.x is not visible..but according to protected access specifier this will work...and one thing that if i make field ' x ' of Test123 as public it is working... How it is possible ...can anybody pls help it out.. Thanx in advance...

    This access is provided even to subclasses that reside in a different package from
    the class that owns the protected feature.As you have found this (and similar) can be confusing.
    Have a look at the Java Language Specification (http://java.sun.com/docs/books/jls/third_edition/html/names.html#6.6.7) "6.6.7 Example: protected Fields, Methods, and Constructors". Can you see the difference between the delta() and delta3d() methods?
    "A protected member or constructor of an object may be accessed from outside the package in which it is declared only by code that is responsible for the implementation of that object." As another example of this, the following compiles OKpackage test2;
    import test1.Test123;
    public class Test234 extends test1.Test123 {
        public static void main(String args[]) {
            Test234 ob = new Test234();
            System.out.println("x=" + ob.x);
    }When run it prints "42" - showing that the same d@mn field is being accessed! Like you, I'd appreciate hearing a simple rationale for this (if there is one).

  • About access specifiers (inheritance)

    abstract Class A
    abstract public add();
    Class B extends A
    protected add() //this wont work
    //some code here
    The access specifier for add method in A is public ,and in B is protected.This is not allowed by compiler.
    Why cant we make the access weaker in the sub class?What is the drawback in allowing to make the access weaker.

    Because any class that uses class A has the right to expect to use the add() method, since it is public in A. Since B is an A, it must allow some one to use an instance of B as if it were an A.

  • Comparing access specifiers  Protected

    Why protected access specifiers are used ? .
    Where comes the difference of using
    void fun1(int a,intb)
    and
    protected void fun(int a, int b)
    }

    From http://www.rijas.t35.com ,
    Note that I did experiment in a variable as protected
    not in a method
    I did both but saw no diffrence from
    no-access Specifiers and
    protected access specifiers
    I extend it two times and
    used package one time
    but saw no difference .
    I am sure ...U can help me !!!
    package pkg;
       class DatePro
           protected  int yy;
       class DatePro2 extends DatePro
           protected int mm;
    public class Date extends DatePro2
                   int dd;
              public void getDate()
                        System.out.println(dd+" "+mm+" "+yy);
           public  void setDate(int d,int m, int y)
                        dd=d;
                        mm=m;
                        yy=y;
    import pkg.*;
    class PkgCheck1
             void   pkgCall()
                        int a=100,b=200;
                        Date d1=new Date();
                        d1.setDate(10,5,07);
                        d1.getDate();
    class PkgCheck2 extends PkgCheck1
                 public static void main(String args[])
                    PkgCheck2 p1 =new PkgCheck2();
                   p1.pkgCall();
                    System.out.println("Hi  I am Rijas P A "+ " You  create a folder pkg  and place Date.java in it");
                    System.out.println("Place PkgCheck2.java - above that folder compile and run PkgCheck2.java");
    thank you...
    Edited by: omnie on Oct 26, 2007 4:27 PM

  • Public Access Point Security

    Hi,
    Is it possible to extend the concept of layer 2 ethernet vlans to wifi networks, with a system that allocates a VLAN per user (allowing 4096 users) on wifi connection?
    I was thinking that this could help prevent Man In The Middle attacks as any new user joining a wifi network would be on their own separate subnet isolated from every other user.
    If this is achieved at the SSID level by assigning each one to a VLAN, is it possible to have this happen automatically?
    Is this how public access points work already and if so how is a MITM attack launched?
    Thanks.

    yes and no.
    the WLC will only take 512 interfaces so you could do that many /32 subnets if you really wanted to.  But you wouldn't be able to max out the 4096
    But, what you can do, is enable Peer to Peer blocking, which disallows clients to talk to each other on the same WLAN
    HTH,
    Steve
    Please remember to rate useful posts, and mark questions as answered

  • What is the difference between access specifiers and access modifiers?

    what is the difference between access specifiers and access modifiers? are they same? if not what is the difference.

    Access Specifier are used to specifiy how the member variable ,methods or class to other classes.They are public ,private and protected.
    Access Modifier:
    1.Access
    2.Non Access
    Access:
    public ,private,protected and default.
    Non Access:
    abstract,final,native,static,synchronized,transient,volatile and strictfp

Maybe you are looking for

  • Retrieve XMLP documents directly from BLOB fields in E1; Tools Release 8.97

    Hi, I want to be able to retrieve XML Publisher reports (PDF, RTF, HTML) directly from the database BLOB fields in EnterpriseOne. Instead of making users manually save each report to get a soft-copy of the report, I wanted to be able to retrieve the

  • External Hard Drive and iTunes

    I've been having a problem lately with one of my USB outlets, and evidence of that is provided by the fact that my External Hard Drive icon on my bottom right task tray keeps repeating the fact that it's plugged in. The wire is loose or something, bu

  • Itunes Malfunction

    Recently my itunes just stopped working, and now when I click to open it an error pops up sayin"Itunes connot open because required files are missing. Please re-install." So I went to apple.com to download most recent itunes and when I try to install

  • Using Dynamic Query in For Loop

    I have a doubt whether i can use the result from dynamic query in the for loop. for example, declare v_sql varchar2(1000); v_Id INTEGER; begin v_sql := 'select id from table1 where id in ('||v_Id||')'; FOR i in vsql LOOP dbms_output.put_line(i.id); e

  • Two lagging issues

    Hello, Two issues with my 2005 Powerbook 1. When turning it on, it hangs on that gray screen with the apple logo and the little circle spinning for about three minutes. While it's doing this, there's a very faint sound coming from the computer as if