Java Most Specific Method

Considering the most specific method in overriden methods, could somebody explain as to what would be the output of the following program and why ?
public class SuperClass {
     public void methodA()
          System.out.println("Name from Super One");
     public void methodA(String... str)
          System.out.println("Name from Super Two");
public class BaseClass extends SuperClass {
     public void methodA(String str)
          System.out.println("Name from Derived");
     public static void main(String args[])
          SuperClass sc=new BaseClass();
          sc.methodA("str");
Edited by: 839760 on Feb 24, 2011 11:23 PM

Or get the real facts from [url http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.12.1]the horse's mouth. But try Kayaman's idea first.
Winston
Edited by: YoungWinston on Feb 25, 2011 3:24 PM
Actually, [url http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.12.2.5]this section is, I think, a bit more specific to what you want to know.

Similar Messages

  • Restrict access to a specific method in JSE

    Hello all,
    I'd like to know if there is a way to restrict access to a specific method in JSE. Basically, my intention is to do this:
    Subject.doAs(subject, new ProtectedMethod());
    // only users with a specific role can access this method
    // (permission specified in my policy file?)
    public class ProtectedMethod implements PrivilegedAction<String> {
       public String run() {
    }I believe that is not possible to specify a method name in policy file via java.lang.RuntimePermission "accessDeclaredMembers", so is there another way to do this?
    Thanks in advance,
    Andre

    I am not an expert of this media hub, but what I would like to know is that are you referring to the security you have setup with the original folders? So after you have created a backup, whatever type of access you have setup was removed? Can you please elaborate?
    Check the FAQ's for NMH305 from here: http://support.linksys.com/en-us/support/storage/NMH305

  • How can we call java control source methods within jsp

    Hi guys!
              How can we access java control source methods that are defined in java control projects within jsp.I am getting error when I tried to call java control source's methods in scriptlet of JSP page.Any help/suggestion is appreciated.
              Thanks
              -Chandu

    Uh, what?
    (And you are sure that it's not a Weblogic-specific question?)

  • Homogeneous system copy ( sapinst or db specific method )

    I want to make homogeneous system copy ( NW7 ) of ECC6 from PRD to make a QA system on HPUX/Oracle environment. I am wondering which of the following method is better way to go
    System copy with the help of sapinst
    or
    Database specific method
    What are the steps of each method?
    Please help, your help will be highly appreciated.
    Best Regards,
    -Al

    Hi Al,
    Using sapinst is the supported method by SAP but it takes much longer as you'll need to export/import the data and doing this affects availability of your PRD system.  Most companies perform DB backup/restore as it is much quicker and does not require an outage of your PRD system (if you have online backups).  Different databases have different tools for this operations.  Since it only a QA system, I would suggest you do a DB backup/restore.
    Regards,
    Thomas Pham

  • Why java allow start() method only once for a thread

    Hi ,
    Why java allows start method only once for thread . suppose
    Thread t = new Thread();
    t.start();
    say at later stage if again we call t.start() IllegalStateException is thrown , even though isAlive method returns false.
    Hence the question , why start() method is allowed only once.If you need start a thread , we need to create a new instance.

    Really. Why do you think that? Do you have any evidence? It is one of the first things I would think of, personally.Considering that the Thread API doesn't allow you to specify a stack address (only stack size), I think it demonstrates they wanted to remove that capability from their Thread API all together. That missing "capability" makes me believe they want me to believe it's not something I need to worry about when using their API... I think the exact semantics of the Thread class and its methods were driven by how to make it most understandable and usable for their customers. I'm certain this issue was one of many that was given considerable thought during the design and implementation of the JVM and the underlying runtime classes.
    Do I have any evidence? No. But if you can point me at some first-hand information on this, I'd love to read it. Most of what I've found is second or third hand accounts. (and I mean that sincerely, not as a smart-ass remark or rebuke of your comments).
    On the one hand you seem to think the Java API designers are idiots, on the other hand you think that they should be. I can't make it out.I thought my position was that the Java developers were talented enough to implement platform in whatever way their API called for; hence, the designers made a choice about how they wanted their API to be used by their customers. They decided which capabilities they wanted to include or exclude, and created an API that was consistent with their vision for this technology. While I'm certain technical limitations had an effect on the API design, I certainly don't think the API was dictated by the them.
    I think the current design of the Java Thread API was a reflection of their vision to make Threading easier and more accessible to Joe Programmer, not limitations in the implementation. I never said it was wrong or that I could do better... I just said I think they could have done something different if they decided it would have made for a better customer experience. But hey, maybe I'm wrong.

  • Transaction timeout configuration for specific method

              Hi,
              How can i configure a transaction timeout for a specific method in EJB using a
              deployment descriptor (using weblogic 8.1)
              Amos.S
              

    There is another way but I think it's more complicated.
    After reading the file you can use a java code (java embedded activity) and split the file.
    For each part of the split you can PUT by FTP the file with append mode. That way your transaction will run in few cycles with less time.

  • Java Language Specification error reports

    Well, I wanted to report a typo in The Java Language Specification, Third Edition (http://java.sun.com/docs/books/jls/download/langspec-3.0.pdf), so from http://java.sun.com/docs/books/jls/ I clicked on the "feedback form" link (which points at http://developers.sun.com/contact/feedback.jsp?&category=doc&mailsubject=Java%20Language%20Specification%20Feedback). This was redirected to http://www.oracle.com/technetwork/community/join/overview/index.html which offers no such feedback form. Consider this sort-of-broken link as the first problem I'm reporting.
    The second problem is in the aforementioned pdf, section 4.8 (Raw Types), page 58, where on can read:
    "The type of the member(s) of Inner depends on the type parameter of Outer. If Outer is raw, Inner must be treated as raw as well, as their is no valid binding for T."
    This should be instead:
    "The type of the member(s) of Inner depends on the type parameter of Outer. If Outer is raw, Inner must be treated as raw as well, as there is no valid binding for T."
    I think a forum category should be created for just this: error reports about the documentation (pdfs, APIs, support web pages).
    Edited by: Urhixidur on 2011-09-08 09:23

    Your intentions are admirable, but you are probably wasting your time. This is a forum for Java development related questions and 99.5% of the visitors are not related to Oracle at all. most likely nothing will be done with your information.
    I think a forum category should be created for just this: error reports about the documentation (pdfs, APIs, support web pages).It is a good idea actually, but such a thing would need very tight moderation and then there is still the question of how to arrange that something is actually done with the reports.

  • Enums with constant-specific method implementation

    Just faced the following problem. I have a persistent class with one of the fields of it is enum with constant-specific method implementation:
    @Persistent
    public class Message
       static public enum Type
           DEFAULT
               @Override
               public String getDescription() { return "Some description"; }
           public abstract String getDescription();
       private Type type;
    }When I try to store the record, I get the exception:
    java.lang.IllegalArgumentException: Class could not be loaded or is not persistent: messages.Message$Type$1The problem seem to be in that compiler creates a separate class, namely Message$Type$1.class for the DEFAULT instance and this class is not known by BDB..
    If I remove the constant-specific method from enum, everything's working fine (as the ..$1.class is not created by compiler).. Except the fact that I'd like to have constant-specific methods there..
    Any ideas on this? Maybe it's a bad idea to create constant-specific methods if it means that each constant would get own class file (and they would bloat the storage routines)?

    Hi Mikhail,
    I recreated the problem here and you're right, constant-specific methods aren't working. This isn't something we thought about, to be honest, or tested.
    Just based on an initial quick look I see that for the compiler generated class, the Class.isEnum method returns false, which is why we don't recognize this as an enum and eventually why we throw the exception you're seeing. But assuming that we can identify the class as an enum (that shouldn't be too difficult) I don't know what other problems we will run into in trying to support this.
    For now I think the best thing is to avoid using the constant-specific methods. I have opened a ticket (#18357) so that we'll remember to look into this in more detail and see whether it can be supported in the future.
    If we are able to support it, then I'm hoping that we won't to store extra metadata for constants that have methods. In other words, I'm hoping that we won't have to add any extra storage or processing overhead.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Java language specification

    1. Need most full on-line java language specification.
    2. How to convert String to int?

    You can convert only string wrapped numbers in to
    int, not all strings.wrong. It all depends on the algorithm you use and
    what meaning you wish to assign to the outcome...
    Take a hashcode for example, you can create one from
    a string and it is an integer value.I think he meant one can only parse strings containing "0-9" to int's.
    That is not true of course, because you can parse strings with base > 10.

  • Where could I find java coding specification

    Where could I find java coding specification.
    I don't know what it really names for, I think it gives a principle for how to coding java program.
    For example, it will tell us which one is better between "final static" and "static final"

    For example, it will tell us which one is better
    between "final static" and "static final"neither of these, it's
    static public final
    Rules:
    first static as theses are class
    variables/methods that don't need instantiation. Then
    the non-static fields/methods. Therefore, "static"
    should be the first keyword for clean grouping.
    Then the visibility like public, protected,
    private (in this order) should be used. (see
    [url=http://java.sun.com/docs/codeconv/html/CodeConven
    tions.doc2.html#1852]Instance variables).Afterwards use final which should be the last
    keyword before the variable type / method return type
    / method parameter type, e.g.
    static public final doThis(final String key) {
    }If these are the "rules", then why is the convention for the main function
    public static void main(String[] args)?

  • InitialContext.doLookup - One of the most dangerous methods ever?

    Heya all;
    I seem to have so many problems with the doLookup method - and wonder if anybody else has experienced the same problems?
    Firstly; doLookup is a static method; yet this is not obvious as it is surrounded by other (instance) lookup methods.
    For example; the following code will obviously not work. This is an easy mistake to miss (although I know many IDE's will warn you of this)
    Properties p = loadProperties();
    new InitialContext(p).doLookup("target");Secondly (and much worse IMO); the appalling (and unforgivable) use of useless type parameters in the method signature; causing compile-time type safety to be completely lost! I would MUCH rather the method was de-generised and have an explicit cast than the dangerous, implicit cast used here!
    public static <T> T doLookup(String name) throws NamingException
            return (T) (new InitialContext()).lookup(name);
    }Sorry for my rant; I just had to get this off my chest:)
    Edited by: alanmp on 09-Jun-2009 10:11

    Firstly; doLookup is a static method; yet this is not obvious as it is surrounded by other (instance) lookup methods.The same applies to any static method. It is as obvious as the Java Language Specification can make it. The word 'static' in the signature tends to act as a bit of a hint. And in fact each doLookup() method is 'surrounded' by one static method and one non-static method.
    Secondly (and much worse IMO); the appalling (and unforgivable) use of useless type parameters in the method signature;I agree with that but the fault is Generic ;-) Parameterised return types are inherently non-type-safe. It's a mystery to me why the feature is there at all considering the stated purpose of Generics. See [this discussion|http://forums.sun.com/thread.jspa?forumID=316&threadID=5346087].

  • Error while opening a dwg file :java.lang.NoSuchMethodException: Method

    Hello Experts,
    I tried to integrate WebCenter Content with Autovue ,the integration was good untill i get this error while trying to open a dwg file checked in Content Server using View in Autovue option in Actions :
    java.lang.NoSuchMethodException: Method fileOpen(com.cimmetry.core.SessionID, com.cimmetry.core.DocID, com.cimmetry.core.Authorization, <null>, java.lang.Boolean, <null>) not found in class com.cimmetry.jvueserver.VCETConnection
         at com.cimmetry.jvueserver.ar.a(Unknown Source)
         at com.cimmetry.jvueserver.ar.a(Unknown Source)
         at com.cimmetry.jvueserver.ar.a(Unknown Source)
         at com.cimmetry.jvueserver.ar.d(Unknown Source)
         at com.cimmetry.jvueserver.ar.a(Unknown Source)
         at com.cimmetry.jvueserver.ah.run(Unknown Source)
    Any suggestions would help me,
    Thanks in Advance
    Raj

    Hi Raj,
    The solution to this problem is posted in My Oracle Support:
    Error: "java.lang.NoSuchMethodException: Method fileOpen" when Trying to View Files Using AutoVue Integrated to Oracle Universal Content Management (UCM) (Doc ID 1341644.1).
    It has all the details, step by step.
    Jeff

  • Error:java.lang.Double:method parseDouble(Ljava/lang/String;)D not found.

    Hi ,
    oracle apps version : 11.5.10.2 and database version 11.2.0.2.
    OS version Solaris Sparc 64 Bit.
    We were performing a cloing activity on a new server and now while opening forms we are getting the following error :
    error:java.lang.Double:method parseDouble(Ljava/lang/String;)D not found.Please suggest what has to be done.
    Regards
    Kk

    Hi ,
    D:\Documents and Settings\800045916>java -version
    java version "1.6.0_29"
    Java(TM) SE Runtime Environment (build 1.6.0_29-b11)
    Java HotSpot(TM) Client VM (build 20.4-b02, mixed mode, sharing)We have been struggling with the Solaris server for this. Is something needed from there also or just need to have the latest JRE in the windows client machine.
    Regards
    Kk

  • Java.sql.Blob method setBinaryStream?

    Hi,
    I've been trying to use the java.sql.Blob methods instead of the "Oracle Extensions" so that people w/o Oracle (using MySQL etc.) can still use my code.
    Problem: trying to get the OutputStream to write to the Blob. As of JDK1.4, java.sql.Blob has a method to do this, setBinaryStream. Unfortunately, calling this in Oracle JDBC (tried it in both thin and OCI version) throws an SQLException (Unsupported feature).
    Sample code:
    //Assume we already have a connection to the database, over either OCI or thin.
    //Assume a Statement stmt created from the connection.
    //Assume a table BlobTable with 2 fields : id (number) and data (blob).
    public void uploadBlob(byte [] theBytes){
         try{
         stmt.executeUpdate("INSERT INTO BlobTable (id, data) VALUES (1,empty_blob())");
         ResultSet rs = stmt.executeQuery("SELECT data FROM BlobTable WHERE id=1 FOR UPDATE");
         if (rs.next()){
    java.sql.Blob blob=rs.getBlob(1);
         OutputStream out=blob.setBinaryStream(0);
         //Next line never printed - error thrown.
         System.out.println("Got Stream");
         catch(Exception e){e.printStackTrace();}
    //End code
    Am I doing something wrong? Or is there simply no way to write to a Blob without using the extensions?
    None of the docs (examples, guides, etc) make any mention of this, although the JDBC dev guide does mention that the similar method in PreparedStmt only works over OCI.
    Thanks,
    Dan

    Hi lancea,
    It's been a while since this thread was active, but I have a related question.
    Is there a comprehensive list of changes between JDBC 3 and JDBC 4 that makes application not work any more, such as this setBinaryStream issue or the CallableStatement/Named parameters issue that we stumbled upon. We would like to address these issues proactively and not find out about them in production, since we're upgrading from jdk1.4 to jdk6. Oracle has provided us with their changes regarding database versions, but have been less forthcoming with JDBC spec version changes.
    Thanks in advance,
    Thomas Auzinger

  • Java.lang.NoSuchMethodError: java.lang.Float: method parseFloat(Ljava/lang/

    java.lang.NoSuchMethodError: java.lang.Float: method parseFloat(Ljava/lang/String;)F not found
    WHAT WOULD MAKE THIS HAPPEN. THIS SEEMS TO WORK IN JDK1.3.1 BUT NOT IN BLACKDOWN 1.1.3_V3
    THIS IS MY CODE:
    try{
    DecimalFormat dfp = new DecimalFormat( "0.00" );
    if(!Price.equals("")) {
    float MyFloat = Float.parseFloat(Price);
    Price = dfp.format(MyFloat);
    }catch(NumberFormatException nfe){
    PriceValid = 1;

    This error says:
    - There is no method called "parseFloat" that receives a String as parameter in class java.lang.Float.
    Look the method "parseFloat" at the class java.lang.Float!!

Maybe you are looking for

  • How do I back up my ITUNES music?

    I just spent a week going through all my CDs and picking my favorite songs to import onto my nano. After uploading the songs, I deleted them from my library so as not to take up too much space on my computer. (The only ones that remain in I-Tunes are

  • How to create new user with more than one default folder

    hi A new user created in OCS has only one default folder(Inbox). I want to create new user with customized default folder. for example: a new user has more than one default folder(Inbox,Outbox,Draft,Dustbin...) And also I want to automaticly enable t

  • EDI Gateway Setup

    Hi All I need info regarding EDI Gateways(EDI Outbound Transaction setup) I am trying to generate the falt file for Outbound Purchase Order using standard Extract programs. But I am getting empty file. I have gone through some documents available on

  • Disappearing Digital Signatures

    Our drafting group creates multi page sketches, each being a separate PDF file. Each page (PDF) is inserted in to a single PDF file as a composite document. Individual pages are revised occasionally and digitally signed off. The old revision is extra

  • Businessobject.isValid always returns false

    Hi, I have created an object against to BOXXXXX business object by using below method having all the input values to formal arguments. CreateAction(actType As String,sfakna1 As String,Date1 As Date,Date2 As Date,description As String) As BusinessObje