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 555803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:51:10+00:00 2026-05-13T11:51:10+00:00

Trying to get clarifications on when you create a new variable, based on an

  • 0

Trying to get clarifications on when you create a new variable, based on an interface or abstract class, and new it when a specific implementation.

Example:

IBlah blah = new BlahImpl();

How would you read that out?

Is it:

A reference variable blah of type IBlah is instantiated with the class BlahImpl?

And so the reference variable will be bound to IBlah, and hence only have the methods/instance and static variables of IBlah but use BlahImpl classes implementaiton of those properties/vars?

Just trying to get my terminology corrected.

  • 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-13T11:51:10+00:00Added an answer on May 13, 2026 at 11:51 am

    Interfaces and abstract classes can never be instantiated. What you can do as you have in your example is to instantiate a concrete class but assign the resulting object to an interface.

    Consider the following class hierarchy:

        IBlah
          ^
          |
    AbstractBlah
          ^
          |
       BlahImpl
    

    If IBlah is an interface and AbstractBlah is an abstract class and BlahImpl is a concrete class, the following lines of code are all invalid:

    IBlah blah1 = new IBlah();
    IBlah blah2 = new AbstractBlah();
    AbstractBlah blah3 = new AbstractBlah();
    

    The following lines of code are both valid:

    IBlah blah1 = new BlahImpl();
    AbstractBlah blah3 = new BlahImpl();
    

    So you can only instantiate concrete a class but the variable you assign that to can be any super-type (a parent class or interface implemented by the class) of the concrete class.

    You can refer to and use the concrete class through the interface or abstract class variable. In fact this is actually encouraged as programming to an abstract class (or interface) makes your code more flexible.

    It is possible to create a concrete class from an interface or abstract class in in-place. So if we have an interface like this:

    interface IBlah {
        void doBlah();
    }
    

    That interface could be implemented and instantiated in one fell swoop like so:

    IBlah blah = new IBlah() {
        public void doBlah() {
            System.out.println("Doing Blah");
        }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 274k
  • Answers 275k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Have you tried Component.getLocationOnScreen()? May 13, 2026 at 2:28 pm
  • Editorial Team
    Editorial Team added an answer I'm not sure exactly what you mean..."to our system" but… May 13, 2026 at 2:28 pm
  • Editorial Team
    Editorial Team added an answer There isn't a way of finding out — you should… May 13, 2026 at 2:28 pm

Related Questions

Are there any good language-agnostic distributed make systems for linux that are secure and
So I'm attempting to use the MVC pattern for a game I'm working on.
I was trying to get clarification on this: Method-1: Dim request = CreateRequest(uri) //some
I'm using ASP.NET MVC and would like to get Model information for use within
RESOLVED After much confusion and frustration, I finally got my hard disk to interrupt.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.