Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6477459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:57:01+00:00 2026-05-25T06:57:01+00:00

From The Java Tutorials : In Java, a class can inherit from only one

  • 0

From The Java Tutorials:

In Java, a class can inherit from only one class but it can implement
more than one interface. Therefore, objects can have multiple types:
the type of their own class and the types of all the interfaces that
they implement. This means that if a variable is declared to be the
type of an interface, its value can reference any object that is
instantiated from any class that implements the interface
.

Can anyone provide me a basic pseudo type for this. I did not understand the bold lines.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:57:02+00:00Added an answer on May 25, 2026 at 6:57 am

    Let’s declare two interfaces and a class that implements them both:

    interface I1 { }
    
    interface I2 { }
    
    class C implements I1, I2 { }
    

    objects can have multiple types

    In the following code, it can be seen that a C instance has the type of C as well as I1 and I2:

    C c = new C();
    
    boolean isC = (c instanceof C);   //true
    boolean isI1 = (c instanceof I1); //true
    boolean isI2 = (c instanceof I2); //true
    

    Now let’s declare a class B which implements I1 as well:

    class B implements I1 { }
    

    if a variable is declared to be the type of an interface, its value can reference any object that is instantiated from any class that implements the interface.

    If we declare a variable of type I1, we can set it to an instance of C, and then reassign it to an instance of B:

    I1 i1 = new C();
    i1 = new B();
    

    We can also reassign it to an instance of D, where D extends C:

    i1 = new D();
    
    ...
    
    class D extends C { }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I came from Java, and now I am working more with Ruby. One language
I read the Java tutorials on Sun for JAR files, but I still can't
I'm trying to call SendMessage with an uint parameter from Java, but I can't
When launching a process from Java, both stderr and stdout can block on output
How can I write from Java to the Windows Event Log?
How do I set environment variables from Java? I see that I can do
Related to my previous question: Call repaint from another class in Java? I'm new
I am trying to create a browser based application that can access Java Objects
I am coming from Java and am currently working on a C# project. What
I need to calculate Math.exp() from java very frequently, is it possible to get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.