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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:39:21+00:00 2026-06-01T05:39:21+00:00

Can anyone tell me what is wrong with this code? public abstract class BoardTestBean{

  • 0

Can anyone tell me what is wrong with this code?

public abstract class BoardTestBean{
    protected String month;
    protected String day;
    protected String name;


    public String getMonth() {
        return month;
    }
    public void setMonth(String month) {
        this.month = month;
    }
    public String getYear() {
        return day;
    }
    public void setYear(String day) {
        this.day = day;
    }
    public String getName(){
        return name;
    }


    //Classes
    public class SAT {
        boolean pre2005=false;
        private String verbal;
        private String quantitative;
        private String writing="";//if pre-2005, do not set. It is not used. 

        public SAT() {
            super();
            if(pre2005)
                name="SAT (pre 2005)";
            else
                name="SAT";             
        }
        public SAT(String verbal, String quantitative, String writing) {
            super();
            this.verbal = verbal;
            this.quantitative = quantitative;
            if(writing!=null && !writing.isEmpty())
                this.writing = writing;
            else
                pre2005=true;
            if(pre2005)
                name="SAT (pre 2005)";
            else
                name="SAT"; 
        }
        public String getVerbal() {
            return verbal;
        }
        public void setVerbal(String verbal) {
            this.verbal = verbal;
        }
        public String getQuantitative() {
            return quantitative;
        }
        public void setQuantitative(String quantitative) {
            this.quantitative = quantitative;
        }
        public String getWriting() {
            if(!this.pre2005)
                return writing;
            else
                return "";
        }
        public void setWriting(String writing) {
            this.writing = writing;
        }
        public boolean isPre2005() {
            return pre2005;
        }
        public void setPre2005(boolean pre2005) {
            this.pre2005 = pre2005;
        }
    }
}

It keeps saying:

No enclosing instance of type AddBoardTestCommand.BoardTestBean is
accessible. Must qualify the allocation with an enclosing instance of
type AddBoardTestCommand.BoardTestBean (e.g. x.new A() where x is an
instance of AddBoardTestCommand.BoardTestBean).

when I try to do this:
SAT bean = new SAT();
with SAT imported as AddBoardTestCommand.BoardTestBean.SAT

I don’t understand why it is asking me to initialize the BoardTestBean class when it is abstract. It is meant to just hold the values for several subclasses (SAT is not the only subclass. I just omitted the others for simplicity).

Can anyone tell me what’s wrong? Thanks.

  • 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-01T05:39:23+00:00Added an answer on June 1, 2026 at 5:39 am

    This is because SAT class is an inner class of BoardTestBean, but not a static inner class. Only static inner classes can be instantiated without an “enclosing” instance context; non-static need a “parent” instance.

    If SAT does not need to use any of the BoardTestBean‘s state, declare it static; otherwise, add an instance method to BoardTestBean and instantiate SAT from there.

    P.S. I am assuming that you are accessing SAT from the same package, because it has package visibility. If this is not intentional, you will need to make the class public as well.

    EDIT This is how you add an instance method to BoardTestBean returning SAT:

    SAT makeSAT() {
        return new SAT();
    }
    

    Now outside BoardTestBean you can do this:

    // assuming that you have an instance of BoardTestBean...
    BoardTestBean myBean = ...
    BoardTestBean.SAT = myBean.makeSAT();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone tell me what's wrong with this code? class Dataset < ActiveRecord::Base has_many
Can anyone tell what is wrong with this piece of code? template<class X> class
Can anyone tell me what's wrong with this code? It's giving me an error
Can anyone tell me whats wrong with this code? <?php $feedID = '28241415'; $oddsArray
Can anyone tell me what is going wrong with this code? I tried to
Can anyone tell me whats wrong in this code? when i try this i
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
Can anyone tell me what I a doing wrong with this code? I am
Can anyone tell me what is wrong with this code? I'm trying to determine
Can anyone tell me what's wrong with this piece of code? I can't seem

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.