4 Replies - 300 Views - Last Post: 17 May 2020 - 07:27 PM Rate Topic: -----

#1 hellswindstaff   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 37
  • Joined: 27-February 12

inheritance and instance variables

Posted 17 May 2020 - 04:22 PM

Earlier in the chapter I read, "However the private instance variables of the superclass are inaccessible. Because these variables are private data of the superclass, only the superclass has access to them. The subclass has no more access rights than any other class."

At the end of the section in the review questions:
public class Employee
{
     private String name; 
     private double baseSalary
     
     ...
}



"Which instance variables does the Manager class have?" Manager extends Employee. According to the review questions' answers include name and baseSalary. So I'm confused because aren't instance variables inaccessible to the subclass?

Is This A Good Question/Topic? 0
  • +

Replies To: inheritance and instance variables

#2 macosxnerd101   User is online

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12761
  • View blog
  • Posts: 45,947
  • Joined: 27-December 08

Re: inheritance and instance variables

Posted 17 May 2020 - 04:27 PM

The variables are still implicitly there in the Manager subclass. However, Manager cannot directly touch them.

In particular, any getter and setter methods from Employee are inherited by Manager, and this is how Manager can interact with these members.
Was This Post Helpful? 0
  • +
  • -

#3 hellswindstaff   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 37
  • Joined: 27-February 12

Re: inheritance and instance variables

Posted 17 May 2020 - 06:24 PM

View Postmacosxnerd101, on 17 May 2020 - 04:27 PM, said:

The variables are still implicitly there in the Manager subclass. However, Manager cannot directly touch them.

In particular, any getter and setter methods from Employee are inherited by Manager, and this is how Manager can interact with these members.


What is meant by "members"?
Was This Post Helpful? 0
  • +
  • -

#4 macosxnerd101   User is online

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12761
  • View blog
  • Posts: 45,947
  • Joined: 27-December 08

Re: inheritance and instance variables

Posted 17 May 2020 - 06:52 PM

The instance variables in the problem statement.
Was This Post Helpful? 0
  • +
  • -

#5 hellswindstaff   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 37
  • Joined: 27-February 12

Re: inheritance and instance variables

Posted 17 May 2020 - 07:27 PM

Okay... thank you :gunsmilie:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1