<< 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.
Damian
yes that's correct
Professor
I think
Professor
what is the stm
Brian Reply
is there industrial application of fullrenes. What is the method to prepare fullrene on large scale.?
Rafiq
industrial application...? mmm I think on the medical side as drug carrier, but you should go deeper on your research, I may be wrong
Damian
How we are making nano material?
LITNING Reply
what is a peer
LITNING Reply
What is meant by 'nano scale'?
LITNING Reply
What is STMs full form?
LITNING
scanning tunneling microscope
Sahil
how nano science is used for hydrophobicity
Santosh
Do u think that Graphene and Fullrene fiber can be used to make Air Plane body structure the lightest and strongest. Rafiq
Rafiq
what is differents between GO and RGO?
Mahi
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
Rafiq
if virus is killing to make ARTIFICIAL DNA OF GRAPHENE FOR KILLED THE VIRUS .THIS IS OUR ASSUMPTION
Anam
analytical skills graphene is prepared to kill any type viruses .
Anam
Any one who tell me about Preparation and application of Nanomaterial for drug Delivery
Hafiz
what is Nano technology ?
Bob Reply
write examples of Nano molecule?
Bob
The nanotechnology is as new science, to scale nanometric
brayan
nanotechnology is the study, desing, synthesis, manipulation and application of materials and functional systems through control of matter at nanoscale
Damian
Is there any normative that regulates the use of silver nanoparticles?
Damian Reply
what king of growth are you checking .?
Renato
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
?
Kyle
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
Adin
why?
Adin
what school?
Kyle
biomolecules are e building blocks of every organics and inorganic materials.
Joe
anyone know any internet site where one can find nanotechnology papers?
Damian Reply
research.net
kanaga
sciencedirect big data base
Ernesto
Introduction about quantum dots in nanotechnology
Praveena Reply
hi
Loga
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?

Ask