Why declare the abstract modifier? -Lesson 1-3 slide 5

In Lesson 1-3 slide 5 the abstract modifier is said for the target method.

Why was this doen? You need the JDK from 8 types of functional interface? What is always optional and strongly discouraged?

The JLS says:

http://Java.Sun.com/docs/books/JLS/second_edition/HTML/interfaces.doc.html

9.1.1.1 abstract interfaces each interface is implicitly abstract. This modifier is obsolete and should not be used in new programs.

And

9.4 abstract method declarations

[...]

For compatibility with older versions of the Java platform, it is allowed but not recommended, as a matter of style, to redundantly specify the modifier abstract for methods declared in interfaces.

It is permitted, but strongly discouraged as a matter of style, to redundantly specify the public modifier for interface methods.

The example in the slide is:

@FunctionalInterface
public interface Runnable {
    public abstract void run();
}

It is true that using "public" and "abstract" on the declarations of interface method is no longer the preferred form, I see that the real source code contains these modifiers! The executable is a very old interface. It was introduced before the JDK 1.0 and indeed that these lines has not changed since its first archived before the JDK 1.0 release. I suspect that Simon may have simply copied this statement directly from source code.

Tags: Java

Similar Questions

  • If you print a document from an e-mail, why is the document different on another computer? The pagination is different, and my boss thought that I modified the document?

    If you print a document from an e-mail, why is the document different on another computer?  The pagination is different, and my boss thought that I modified the document?  I have not change the document - I just printed it e-mail, he says than the version printed on different is his version on his computer - and I have nothing but print it.

    Could answer you my question today?

    Thank you

    Hi MBS_PITT,

    The print can be different depending on the print settings and the settings of the computer on the other computer. If you want the same settings, then you should change the settings accordingly before you take the print out.

    For more information, you can consult the following article:

    Print a document or file

    Hope this information is useful.

  • is not abstract and does not substitute the abstract method callLogRemoved (net.rim.blackberry.api.phone.phonelogs.CallLog)

    Can someone tell me why im getting the following error

    is not abstract and does not substitute the abstract method callLogRemoved (net.rim.blackberry.api.phone.phonelogs.CallLog)

    callLogRemoved is set, I tried to remove it and it also gives me the same error

    Here is my code

    Thanks in advance for answer

    Net.rim.blackberry.api.phone import. *;
    Net.rim.blackberry.api.phone.phonelogs import. *;
    //*******************************************************************************//
    public class mylistener extends Thread implements {PhoneLogListener}

    {} public void callLogRemoved (int arg0)
    System.out.println("/***/"); "
    System.out.println ("CallLog removed');
    System.out.println("/***/"); "
    }
    {} public void callLogAdded (int arg0)
    System.out.println("/***/"); "
    System.out.println ("CallLog added");
    System.out.println("/***/"); "
    }
    ' public void callLogUpdated (int arg0, int arg1) {}
    System.out.println("/***/"); "
    System.out.println ("CallLog update");
    System.out.println("/***/"); "
    }
    {} public void reset()
    System.out.println("/***/"); "
    System.out.println ("CallLog Reset");
    System.out.println("/***/"); "
    }

    }

    Javadoc documentation:

    public void callLogRemoved (CallLog cl)

    but you have coded:

    public void callLogRemoved (int arg0)

    An int is not a CallLog, so these signatures do not match.

  • Assign dynamic statement declaring the block or block start

    Hi all

    For code below, if I attribute the select statement in the section declare for the corresponding variable, it will improve performance.

    For cust_veh_id we have another block cursor to declare, only partial code is provided.


    What I wanted to.
    declare
    v_addr_chg_stmt                 varchar2(2000) := 'select ''Y''
    FROM cust_addrs addrs
    WHERE customer_id = :v_customer_id
    AND updated_date >:p_end_date
    and rownum = 1';
    Actaul
    ---------
    declare
    p_end_date                      date;
    v_addr_chg_stmt                 varchar2(2000);
    v_mileage_stmt                 varchar2(2000);
    begin
    
    select updated_date into p_end_date
    from process_log_rfsh
    where tran_code ='CAP';
    
    v_addr_chg_stmt :=
    'select ''Y''
    FROM cust_addrs addrs
    WHERE customer_id = :v_customer_id
    AND updated_date >:p_end_date
    and rownum = 1'
    ;
    
    v_mileage_stmt :=
    'SELECT ''Y'' FROM cust_vehicles_audit
    WHERE cust_veh_id=:v_cust_veh_id
    AND field_name =''LAST_MILEAGE''
    AND added_date > :p_end_date
    and audit_date >= trunc(:p_end_date)
    and rownum=1'
    ;
           begin
                     execute immediate v_addr_chg_stmt
                        into v_addr_change_flag
                        using v_customer_id,  p_end_date;
                 exception
              when no_data_found then
                     v_addr_change_flag:='N';
                 end;
            begin
                   execute immediate v_mileage_stmt
                     into v_mileage_change_flag
                    using v_cust_veh_id,  p_end_date, p_end_date;
               exception
             when no_data_found then
                   v_mileage_change_flag:='N';
               end;
    end;
    Thank you
    Rambeau

    Published by: Raghu on January 18, 2013 13:13

    Rambeau wrote:
    This code is already running in production for a few years.

    Not a reason to justify using dynamic SQL.

    YOU NEED a JUSTIFICATION FOR the USE of DYNAMIC CODE. In any language.

    Once again: WHAT is your justification? If you can't provide that, so why you use code Dynamics?

    If you must use dynamic sql statements, performance definition wise to declare the block or start will be better.

    No difference - as no method doesn't change the actual SQL cursor run. Nor did the resulting cursor read faster data blocks.

    PL/SQL also does not care where the variable assignment happens. The difference is so small and so small, it is not relevant to the performance:

    SQL> declare
      2          t1      timestamp;
      3  begin
      4          --// test 1
      5          t1 := systimestamp;
      6          for i in 1..10000 loop
      7                  declare
      8                          num     number;
      9                  begin
     10                          num := 1;
     11                  end;
     12          end loop;
     13          dbms_output.put_line( 'Test 1. '||to_char(systimestamp-t1) );
     14
     15          --// test 2
     16          t1 := systimestamp;
     17          for i in 1..10000 loop
     18                  declare
     19                          num     number := 1;
     20                  begin
     21                          null;
     22                  end;
     23          end loop;
     24          dbms_output.put_line( 'Test 2. '||to_char(systimestamp-t1) );
     25
     26  end;
     27  /
    Test 1. +000000000 00:00:00.000040000
    Test 2. +000000000 00:00:00.000024000
    
    PL/SQL procedure successfully completed.
    
    SQL>
    
  • Clean the Code example for the abstract factory

    Hello
    I read clean Code and I do not understand something.
    On page 38, it is suggested to instead use the switch instructions, we can use the abstract factory.
    The example is the following:
    Instead:
    public Money calculatePay(Employee e)
    throws InvalidEmployeeType {
      switch (e.type) {
      case COMMISSIONED:
        return calculateCommissionedPay(e);
      case HOURLY:
        return calculateHourlyPay(e);
      case SALARIED:
        return calculateSalariedPay(e);
      default:
        throw new InvalidEmployeeType(e.type);
      }
    }
    We can do this:
    public abstract class Employee {
      public abstract boolean isPayday();
      public abstract Money calculatePay();
      public abstract void deliverPay(Money pay);
    }
    -----------------
    public interface EmployeeFactory {
      public Employee makeEmployee(EmployeeRecord r) throws InvalidEmployeeType;
    }
    -----------------
    public class EmployeeFactoryImpl implements EmployeeFactory {
      public Employee makeEmployee(EmployeeRecord r) throws InvalidEmployeeType {
        switch (r.type) {
         case COMMISSIONED:
            return new CommissionedEmployee(r) ;
         case HOURLY:
            return new HourlyEmployee(r);
         case SALARIED:
            return new SalariedEmploye(r);
         default:
            throw new InvalidEmployeeType(r.type);
         }
      }
    }
    I don't see why the plant is necessary here. (I know not much make abstract and I am a beginner)
    The abstract class used with his methods wouldn't be enough? Subclasses (CommissionedEmployee, HourlyEmployee,...) are implemented methods that can be called when necessary. Instead of calculatePay (myEmployee), we call myEmployee.calculatePay (). Doesn't it all? So I don't know why the plant is located in this example.

    Thanks in advance for any help on this!

    lemonboston

    lemonboston wrote:
    Subclasses (CommissionedEmployee, HourlyEmployee,...) are implemented methods that can be called when necessary. Instead of calculatePay (myEmployee), we call myEmployee.calculatePay (). Doesn't it all?

    Well, Yes, that's all. Almost everything is. You're right, you call

    myEmployee.calculatePay()
    

    where "myEmployee" is an object of the appropriate subclass. But whence this object? At some point, you must have had a line that says

    Employee myEmployee = new SalariedEmployee()
    

    or something along that line. But how did you know to create a SalariedEmployee object and not a HourlyEmployee object? It must have been a few if statements going on there. And here comes the factory: you pass a token representing the employee at the factory (a type code of employee of a character, an employee number that it will search in a database, or something else) and the factory returns a derived object of this token.

  • Why use an abstract class?

    I am new to Java, and for some reason I can't get my head around why use an abstract class. I understand that an abstract class is something like:
    public abstract class Food{ // abstract class
    
    public void eat(){
    // stub
    }
    
    }
    
    public class Apple extends Food{
    
    public void eat(){
    // Eat an apple code
    }
    
    }
    So basically the idea above is that you can eat a "Apple", but you can't eat "food" because you cannot instantiate an abstract class.

    I understand what an abstract class is and how to write a. What I don't understand is why you would use it? It seems to me I might just create a normal class, called 'Food' and just do not instantiated. What are the benefits of using an abstract class?

    807479 wrote:
    If an abstract class should be used when you can implement fully some of the methods, but the other method can only be defined as heels?

    Fix.

    Note that Java abstract classes aren't necessary, but they add comfort and a way to correctly model the ideas we try to represent.

    That is why it must be abstract because you can not instantiate the class because not all methods are completely formed?

    Yes pretty close.

    So basically in an example of a mammal, I might have a breath() method entirely defined in the abstract class because all breath of mammals.
    But I should only do a method stub for speak() like any mammal makes a different sound.

    Right.

    Now I can not instantiate a mammal because it has only a stub for the speak() method so it must be an abstract class.

    Fix. There is no common way speak all mammals.

    But if I create a class called cow and extend the class mammal I only need to write the speak() method as I can inherit the breath() method completely trained.

    Is this correct? I am an abstract class if I can't entirely make up together the method. But I use an abstract class when I can form some of the methods?

    Your terminology is a little off, but, Yes, it seems that you have understood the concepts.

  • Why HttpServlet is abstract, even if all methods are practical?

    Hello

    Why HttpServlet is abstract, even if all methods are concert?

    You cannot create an instance of this of course.

    Even if all methods are concrete, you should always provide your own implementation of at least one of the methods before it will do anything.

  • Why does the video appear darker it is?

    Hello

    I used FCPX for a few years but I started on FCP and must go back occasionally.

    I don't know how or why, but the images in the viewer and canvas appears darker than it really is. But when I export without problem, everything's fine.

    Any ideas? At something I touched on by mistake?

    What's also weird is, there is no record for the FCP or FCS in the Applications folder. There should not be? In one case, shouldn't be Qmaster or something or other? I just installed FCP of FCS on my new MBP 8 months past, but maybe I trashed a few things by mistake. Should I color or any other application?

    The best

    Elmer

    Go to the Final Cut Pro menu > Control Panel and click on playback control tab Gamma Correction value to approx...

    MtD

  • Why are the games on the App Store different from an iPhone to an iPad?

    Why are the games on the App Store different from an iPhone to an iPad?

    Because they are different devices and not all applications run on both.

  • Why "towards the high following" only it displays 20 songs?

    This is less of an issue that needs resolving and more a curiosity I had for a while.

    In iTunes, why "towards the high following" only displays a maximum of 20 songs instead of the rest of your playlist?

    There is no 'show more' button or option to increase the amount of somewhere, so I don't think it's just an arbitrary amount.

    I don't think that it's one thing to user experience either. Watch 'Recently played' WAY more songs, so there is no reason not to do with «To the top next»

    It might have something to do with the shuffle function? Like, if only about 20 songs are mixed and added to the queue until the next at some point, to make the application run faster?

    I am very interested to hear your thoughts on this subject.

    Nobody here knows why Apple did something and the speculation is not allowed.

  • Why is the game number facilitates the registration of parts made on my iMac, but not on my iPod?

    Why is the game number facilitates the registration of parts made on my iMac, but not on my iPod?

    Your iPod is synchronized or be managed manually? If you sync game should update the counts. In iTunes > Preferences > Store you have given reading synchronized between compatible devices?

    TT2

  • Why is the 200 GB $44.99 a plan inherited from year more expensive than the monthly plan the new 200 GB $2.99 a month plan ($35,88) - what's the catch here?

    Why is the 200 GB $44.99 a plan inherited from year more expensive than the monthly plan the new 200 GB $2.99 a month plan ($35,88) - what's the catch here? is there a reason why the new plan is less expensive? they are trying to phase out the inheritance plan? is there a difference in storage w the new plan and the legacy for the difference in price (of the problems of the different devices w - computer laptop Mac, iPhone, iPad?)

    The only difference is that it is charged monthly.

    As shown in the following, you may be able to increase your storage space or reduce your costs by opting for the monthly package. Annual storage iCloud - Apple Support plans

  • Why does the iTunes on my macbook pro light when my Apple TV turns on.

    Why does the iTunes on my macbook pro light when my Apple TV turns on.

    No idea, mine isn't and I'm reasonably sure he shouldn't, I wonder if I'm not wrong understand what you mean, please specify exactly what is happening.

  • Why do the topics become Chinese when I access my email via Firefox but not Internet Explorer?

    Why do the topics become Chinese when I access my email via Firefox but not Internet Explorer?

    Hello, this is a display caused the extension Advisor default McAfee site - please try to disable or remove that in case you have now until there's a mcafee update that may resolve the problem.

    http://service.McAfee.com/faqdocument.aspx?ID=TS100162
    https://community.McAfee.com/thread/76071

  • Why on the mozilla icon appears and desappears a kind of bubble?

    Why on the mozilla icon appears and desappears a kind of bubble? »

    Hey Galina1
    I'm not sure where did you download and install Firefox from?
    If the icon, here is a solution that changes the icon who is responsible:
    https://support.Mozilla.org/en-us/Que.../976005

Maybe you are looking for