Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
You didn't tell me he was so big. Unlike this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic