• Post Reply Bookmark Topic Watch Topic
  • New Topic

why compile the file there are two class file was created?  RSS feed

 
Gong James
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question 91.
Read the following code excerpt carefully. //Contents of file A.java
Which of the following are true
1.A.java cannot be compiled. Duplicate defination of inner class B.
2.A.java compiles without any error. An attempt to run C as an application will cause runtime linkage error. Duplicate definations of inner class B are found
3.Only one class file corresponding to the inner class B is created in the file system.
4.Two class files corresponding to both inner classes (B) is created in the file system.
5.The classes compile cleanly and on running C as an application causes "I am in the arg constructor" to be printed on the console

the given ans is;4.5.
I dont know why there there are two class file(A$1$B.class ,A$2$B.class)of class B is created when i compiled the code.

(Marilyn added code tags)
[This message has been edited by Marilyn deQueiroz (edited November 03, 2001).]
 
Rashmi Hosalli
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Two class files A$1$B.class and A$2$B.class are created as A.java has two constructors and both of them have inner classes.
Rashmi
 
Arthur King
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the class file of the inner class will be also generated along with the generation of the driver's class. so in this case, A.java has two inner classes B in each of its constructors, therefore, two B.class will be generated.
arthur
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!