<< Chapter < Page | Chapter >> Page > |
A complete listing of the program discussed in this module is show in Listing 25 .
This section contains a variety of miscellaneous information.
Financial : Although the Connexions site makes it possible for you to download a PDF file for thismodule at no charge, and also makes it possible for you to purchase a pre-printed version of the PDF file, you should beaware that some of the HTML elements in this module may not translate well into PDF.
I also want you to know that, I receive no financial compensation from the Connexions website even if you purchase the PDF version of the module.
In the past, unknown individuals have copied my modules from cnx.org, converted them to Kindle books, and placed them for sale on Amazon.com showing me as the author. Ineither receive compensation for those sales nor do I know who does receive compensation. If you purchase such a book, please beaware that it is a copy of a module that is freely available on cnx.org and that it was made and published withoutmy prior knowledge.
Affiliation : I am a professor of Computer Information Technology at Austin Community College in Austin, TX.
Figure 1 - Class files produced when the program is compiled. |
---|
A$B$C$D.class
A$B$C.classA$B.class
A.classInnerClasses06.class
X.class |
Figure 2 - Screen output. |
---|
In xstr for A, objCntA = 1 |
Figure 3 - Screen output. |
---|
In xstr for A, objCntA = 1
In xstr for B, objCntB = 1 |
Figure 4 - Screen output. |
---|
In xstr for A, objCntA = 1
In xstr for B, objCntB = 1In xstr for C, objCntC = 1 |
Figure 5 - Screen output. |
---|
Construct obj of private class D.
Private class file name: A$B$C$D |
Figure 6 - Screen output. |
---|
In xstr for A, objCntA = 2
In xstr for B, objCntB = 2 |
Figure 7 - Screen output. |
---|
-1-
In cShow, objNumber = 1In cShow, cVar = 3 |
Figure 8 - Screen output. |
---|
-2-
In bShow, bVar = 2In bShow, objNumber = 1
In aShow, aVar = 1In aShow, objNumber = 1 |
Figure 9 - Screen output. |
---|
-3-
In aShow, aVar = 1In aShow, objNumber = 1 |
Figure 10 - Screen output. |
---|
-4-
A$B$CA$B$C
A$B$CA$B$C
A$B$C |
Figure 11 - Screen output. |
---|
-5-
A$BA$B |
Figure 12 - Screen output. |
---|
-6-
A |
Figure 13 - Screen output. |
---|
-7-
In cShow, bVar = 20A$B
In cShow, aVar = 10A |
Figure 14 - Screen output. |
---|
-8-
In bShow, bVar = 20In bShow, objNumber = 2
In aShow, aVar = 1In aShow, objNumber = 1 |
Figure 15 - Screen output. |
---|
-9-
In aShow, aVar = 10In aShow, objNumber = 2 |
Figure 16 - Screen output. |
---|
-10-
className = CtoString in Class C
className = XtoString in Class X |
Listing 1 - The main method. |
---|
public class InnerClasses06{
public static void main(String[]args){
new A(1).new B(2).new C(3).cShow();}//end main
}//end class InnerClasses06 |
Listing 2 - The class named X. |
---|
class X{//extends Object by default
protected String className = "X";public String toString(){
return "toString in Class X";}//end overridden toString
}//end class X |
Listing 3 - Beginning of the top-level class named A. |
---|
class A{
private int aVar;private int objNumber = 0;
private static int objCntA = 0;private static int objCntB = 0;
private static int objCntC = 0; |
Notification Switch
Would you like to follow the 'Object-oriented programming (oop) with java' conversation and receive update notifications?