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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:08:59+00:00 2026-05-21T11:08:59+00:00

Background info I have a query regarding a questions from Sierra & Bates, SCJP

  • 0

Background info
I have a query regarding a questions from Sierra & Bates, SCJP v6 book. Namely Chapter 2 question 2. The answer given is that the “compilation fails”. However when I tried this in neBeans, the code compiled and ran without error. It also returned a output of “D” which was not one of the alternatives. There are some other discussions on this same question in various forums, regarding the need to insert super() etc. However none seem to have recognised it can compile.

Question
1. I expected the constructor “Bottom2(String s)…to have called the super constructor “Top(String s)…”. In which case the output would have been “BD” (which happens to be an option for the question. Why does the “Top(String s)…” not get called.
2. As there is a Top constructor then would the default compiler constructor still be implicitly created. ie in effect a “Top() {}” constructor which can be called by “Bottom2(String s)”. This not how I understood this to happen – ie the compiler only creates this default if no other constructor is created.
3. Is there and error in this question, or is this a carry over question from the Java 5 version and somehow in Java 6 the compiler can now handle this.
4. Could netBeans have a means to “solve” the compiler problem. This is quite important as I am studying for the SCJP and I find not all the questions can be duplicated in netBeans. In which case I may learn to believe some code works when (for exam purposes) it does not.

Code included for ease of reference.

class Top { 
    public Top(String s) { System.out.print("B"); } 
} 

public class Bottom2 extends Top { 
    public Bottom2(String s) { System.out.print("D"); } 
    public static void main(String [] args) { 
        new Bottom2("C"); 
        System.out.println(" "); 
    }
}
  • 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-21T11:08:59+00:00Added an answer on May 21, 2026 at 11:08 am

    Top doesn’t have a default constructor (a default constructor is a public constructor with empty argument list. Therefore, the constructor of Bottom2 must explicitly invoke the super constructor (and pass its argument), but doesn’t, and hence compilation fails.

    Indeed, eclipse helios says:

    Implicit super constructor Top() is undefined. Must explicitly invoke another constructor

    and javac says:

    cannot find symbol
    symbol  : constructor Top()
    location: class tools.Top
        public Bottom2(String s) { System.out.print("D"); }
                                 ^
    

    Are you really sure you have tried the same code in Netbeans?

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

Sidebar

Related Questions

Before I begin my question a little background info. I have the WCF service
Please help! Background info I have a WPF application which accesses a SQL Server
Some background info; LanguageResource is the base class LanguageTranslatorResource and LanguageEditorResource inherit from LanguageResource
Here's some background info. I have three MySQL tables (all InnoDB). The first table
Background Info: I have two COM+ components on a remote server, based on .NET
Background info I have an app where users can make microsites ala http://myname.the_app.com .
Some background info: We have several websites running on a 64-bit machine with IIS6
i have a question about a function. function &formatName($id, $name, $clanId, $clanSym, $clanCol) {
Background info I am working my way through Crafting Rails and in Chapter 4
Background Info: I have a program running through a list of url; each URL

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.