• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

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

 
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).]
 
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
 
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!