title: Multiple inheritance for an anonymous class
body: <p>How can an anonymous class implement two (or more) interfaces? Alternatively, how can it <strong>both</strong> extend a class <strong>and</strong> implement an interface?
  For example, I want to create an object of anonymous class that extends two interfaces:</p>
  <pre class="lang-java prettyprint-override"><code>    // Java 10 &quot;var&quot; is used since I don't know how to specify its type
      var lazilyInitializedFileNameSupplier = (new Supplier&lt;String&gt; implements AutoCloseable)() {
          private String generatedFileName;
          @Override
          public String get() { // Generate file only once
              if (generatedFileName == null) {
                generatedFileName = generateFile();
              }
              return generatedFileName;
          }
          @Override
          public void close() throws Exception { // Clean up
              if (generatedFileName != null) {
                // Delete the file if it was generated
                generatedFileName = null;
              }
          }
      };
  </code></pre>
  <p>Then I can use it in a try-with-resources block as <code>AutoCloseable</code> as lazily-initialized utility class:</p>
  <pre class="lang-java prettyprint-override"><code>        try (lazilyInitializedFileNameSupplier) {
              // Some complex logic that might or might not 
              // invoke the code that creates the file
              if (checkIfNeedToProcessFile()) {
                  doSomething(lazilyInitializedFileNameSupplier.get());
              }
              if (checkIfStillNeedFile()) {
                  doSomethingElse(lazilyInitializedFileNameSupplier.get());
              }
          } 
          // By now we are sure that even if the file was generated, it doesn't exist anymore
  </code></pre>
  <p>I don't want to create an inner class because I'm absolutely sure that this class won't be used anywhere except the method I need to use it in (and I also <em>might</em> want to use local variables declared in that method that might be of <code>var</code> type).</p>