C++ Programming: From Problem Analysis To Program Design, Loose-leaf Version
C++ Programming: From Problem Analysis To Program Design, Loose-leaf Version
8th Edition
ISBN: 9781337684392
Author: Malik, D. S.
Publisher: Cengage Learning
Expert Solution & Answer
Book Icon
Chapter 11, Problem 7SA

Explanation of Solution

The inheritance is a public one - the public members of the base class remain public in the derived and the private members of the base class remain private unless re-declared otherwise in the derived class. Hence, the private members of the object newCylinder are the following:

  1. height – as it is the ...

Blurred answer
Students have asked these similar questions
Public classTestMain {     public static void main(String [ ] args)     {          Car myCar1, myCar2;          Electric Car myElec1, myElec2;          myCar1 = new Car( );          myCar2 = new Car("Ford", 1200, "Green");          myElec1 = new ElectricCar( );          myElec2 = new ElectricCar(15);          } }
class overload { int x; double y; void add(int a , int b) { x = a + b; } void add(double c , double d) { y = c + d; } overload() { this.x 0; %3D this.y = 0; } %3D } class Overload_methods { public static void main(String args[]) { overload obj int a = 2; double b - 3.2; obj.add(a, a); obj.add(b, b); System.out.println(obj.x + } = new overload(); + obj.y); } #3Run the code
class Param3 { public int x; private void increase(int p) { x = x*p; } public void calculateX(int y) { increase(y); } public int getX() { return x; } } // in another class Param3 q3 = new Param3(); q3.x = 5; q3.calculateX(7); System.out.println(q3.getX()); what would be the answer for the last two lines ? also above were x = x*p do both x in here are the fields? wouldn't that be cnofusing?
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
  • Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT