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

  • Home
  • SEARCH
  • 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 8787349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:52:10+00:00 2026-06-13T21:52:10+00:00

My question is related to Java language. This is what I got: interface I1{}

  • 0

My question is related to Java language.
This is what I got:

interface I1{}
interface I2{}
class C1 implements I1{}
class C3 extends C1 implements I2{}

When

     C1 01;
     C3 o3;
     I1 i1;

etc

And now it turns out that I2 i2 = (I2) i1; is right because at run time i1 actually refers to an object that implements I2.
But I don’t get it. Interfaces have no relationships between one another, so how can you cast it to an adjacent interface?
There is no more code, it is simply a drill in order to prepare for Java certification.
Best regards

  • 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-06-13T21:52:12+00:00Added an answer on June 13, 2026 at 9:52 pm

    I2 i2 = (I2) i1; means: I know that the concrete runtime type of the object referenced by i1 implements the I2 interface, so I would like to reference it as an I2. If the concrete runtime type of i1 indeed implements I2, the cast will succeed.

    The fact that I1 and I2 have nothing in common doesn’t matter. What matters is the actual concrete runtime type of the object referenced by i1.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is related to Java Refuses To Start - Could Not Resrve Enough
Another question related to this one . I have a List<SortableObjects> that is the
This question is related to my question on existing coroutine implementations in Java .
This maybe a related question: Java assignment issues - Is this atomic? I have
This question is related to Implementing logging in a Java application , but since
not sure if this question should be here or in serverfault, but it's java-related
The answers to this related question of mine lead me to choose Java for
(Related question: Java compilers or JVM languages that support goto? ) I have decompiled
question related to this I have a string a\;b\\;c;d which in Java looks like
This question is related to Java Web Application - File Upload . Is it

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.