Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

bout top-level class

 
jay vyas
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi friends,
Declaration of Top-level class Frog are legal, assuming animal is a existing class
A. protected class Frog extends Animal{}
B. private class Frog extends Animal{}
C. transient clas Frog extends Animal{}
D. native class Frog extends Animal{}
as per my knowledge Top-level class must be either public or default. so that way none of above is correct answer but when i try to compile this code with protected and private modifier their class file created. so what should be the answer ?
thanx in advance
jay...
 
Randall Twede
Ranch Hand
Posts: 4442
3
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get a compile time exception "Syntax Error" when i try to make top level class protected or private.
 
jay vyas
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Randall Twede:
I get a compile time exception "Syntax Error" when i try to make top level class protected or private.

thanx Randall,
but if u have noticed then there will be class file created for protected and private modifier
 
Randall Twede
Ranch Hand
Posts: 4442
3
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes i have heard of this before. it creates the class file even when the compiler throws an exception.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic