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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:19:52+00:00 2026-05-30T02:19:52+00:00

I was reading the OCPJP (SCJP) book, when I came across this question in

  • 0

I was reading the OCPJP (SCJP) book, when I came across this question in chapter 2.

class Uber{
 static int y= 2;
 Uber(int i){
    this();
    y = y*2;
 }

 Uber(){
    y++
 }

}

class Minor extends Uber{
 Minor(){
    super(y);
    y=y+3;
 }

 public static void main(String[] args){
    new Minor();
    System.out.println(y);
 }

}

The book says the answer should be 9, but I’m confused as to whether the compiler will recognize the y in super(y);. If it does how can that be?

Thanx in advance.

  • 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-30T02:19:54+00:00Added an answer on May 30, 2026 at 2:19 am

    No, the code you’ve given won’t compile. It would compile if Minor extended Uber though – are you sure it doesn’t in the book?

    (Even after getting it to compile, the code prints 7 for me, not 9. I can’t see how it would end up printing 9… it starts at 2, then is doubled to 4, then 3 is added to get 7…)

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

Sidebar

Related Questions

reading the SCJP book, I've found something like this in the chapter 1 self-test
Reading the Scala by Example book and there is this example when Martin explains
Reading the design guidelines. I came across a little issue while trying to practice
Reading through wikipedia I came across the concept of Sprints in Agile development. From
Reading this site, I've found this : [The] line private static final Foo INSTANCE
Reading this question , I wondered how much time (asymptotically speaking) does it takes
Reading this question I found this as (note the quotation marks) code to solve
Reading over the responses to this question Disadvantages of Test Driven Development? I got
Reading on another forum I've came across the world of CSS Frameworks. The one
Reading this fascinating (and highest voted question) on SO, Why is it faster to

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.