<< Chapter < Page Chapter >> Page >

Call the private bShow method

The code in Listing 21 is somewhat more interesting. This code calls the private bShow method on the separate object instantiated from the class named B in order to identify the object to which that object is linked.

The screen output

The output produced by the code in Listing 21 is shown in Figure 14 . Even though this object of the member class B was instantiated from within the constructor for the member class named C, theobject of the class named B is internally linked to the object of the class named A that was originally used to instantiate the object of the class named C.

(See Listing 1 where the objects of classes named A, B, and C were originally instantiated. This object of the class named B is a differentobject from the object of the class named B instantiated in Listing 1 . This object of the class named B was instantiated by the code in Listing 11 .)

How is this determined from Figure 14 ?

The second line in Figure 14 shows that a parameter value of 20 was received by the constructor when theobject of the class named B was instantiated. This corresponds to the instantiation of the object by the code in the constructor in Listing 11 .

The third line in Figure 14 shows that this was the second object instantiated from the class named B. (See the definition of the bShow method in Listing 12 , which displays the value stored in a variable that is used to save the object number.)

The proof of the pudding

Now recall that the method named bShow (belonging to an object of the class B) calls the method named aShow belonging to the object of the class named A to which it is internally linked.

The fourth line in Figure 14 shows the value of the parameter passed to the constructor for the object of class A when that object was instantiated. (See the definition of the aShow method in Listing 13 .) This value corresponds to the value that was passed to the constructor for the original object of class A whenit was constructed in Listing 1 .

(It does not correspond to the value passed to the constructor for the class named A when the object of the class A was constructed in Listing 11 .)

The fifth line in Figure 14 shows that the object was the first object instantiated from the class named A.

Both B objects link to the same A object

Thus, both objects instantiated from the class named B in this program are internally linked to the same object instantiated from the classnamed A, which is the enclosing class for the class named B.

(However, had I instantiated the new object of the class B using a statement such as the following,

new A(100).new B(200).bShow();

the new object of the class B would have been linked to the new object of theclass A rather than being linked to the original object of the class A. As you can see, keeping mental track of which object is linked to which otherobject could become complicated.)

Call the aShow method on the other A object

The code in Listing 22 calls the private aShow method on the independent object of the class A that was instantiated in the constructor for class C, shown in Listing 11 .

Questions & Answers

Preparation and Applications of Nanomaterial for Drug Delivery
Hafiz Reply
Application of nanotechnology in medicine
what is variations in raman spectra for nanomaterials
Jyoti Reply
I only see partial conversation and what's the question here!
Crow Reply
what about nanotechnology for water purification
RAW Reply
please someone correct me if I'm wrong but I think one can use nanoparticles, specially silver nanoparticles for water treatment.
yes that's correct
I think
what is the stm
Brian Reply
is there industrial application of fullrenes. What is the method to prepare fullrene on large scale.?
industrial application...? mmm I think on the medical side as drug carrier, but you should go deeper on your research, I may be wrong
How we are making nano material?
what is a peer
What is meant by 'nano scale'?
What is STMs full form?
scanning tunneling microscope
how nano science is used for hydrophobicity
Do u think that Graphene and Fullrene fiber can be used to make Air Plane body structure the lightest and strongest. Rafiq
what is differents between GO and RGO?
what is simplest way to understand the applications of nano robots used to detect the cancer affected cell of human body.? How this robot is carried to required site of body cell.? what will be the carrier material and how can be detected that correct delivery of drug is done Rafiq
analytical skills graphene is prepared to kill any type viruses .
Any one who tell me about Preparation and application of Nanomaterial for drug Delivery
what is Nano technology ?
Bob Reply
write examples of Nano molecule?
The nanotechnology is as new science, to scale nanometric
nanotechnology is the study, desing, synthesis, manipulation and application of materials and functional systems through control of matter at nanoscale
Is there any normative that regulates the use of silver nanoparticles?
Damian Reply
what king of growth are you checking .?
What fields keep nano created devices from performing or assimulating ? Magnetic fields ? Are do they assimilate ?
Stoney Reply
why we need to study biomolecules, molecular biology in nanotechnology?
Adin Reply
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
what school?
biomolecules are e building blocks of every organics and inorganic materials.
anyone know any internet site where one can find nanotechnology papers?
Damian Reply
sciencedirect big data base
Introduction about quantum dots in nanotechnology
Praveena Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get the best Algebra and trigonometry course in your pocket!

Source:  OpenStax, Object-oriented programming (oop) with java. OpenStax CNX. Jun 29, 2016 Download for free at https://legacy.cnx.org/content/col11441/1.201
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Object-oriented programming (oop) with java' conversation and receive update notifications?