• Post Reply Bookmark Topic Watch Topic
  • New Topic

Beginner Queries.  RSS feed

 
Sunit Kajarekar
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Can a java package and a class have same name

e.g: package P1;
Class P1{
}

This gives a compile time error. Can anyone please explain.

2. Can a nested class(ststic inner class) have same name as the outer class.

3. package p1;

1. class C1{
2. static Class C1{
3. C1.
4. }
5. main(){
6. }
7. }

on line no. 3, which C1 is being reffered? Please Explain.

Thanks.

Regards,
Sunit P. Kajarekar
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Generally, it works better here if you tell us what YOU think. Then someone here can makes suggestions or give you a hint about a different way to think about it. We feel you will learn more, learn it better, and remember it longer if you make the effort to figure it out first.

For example...Q1 you say "It gives a compiler error". Compiler errors actually TELL you stuff. They are strong hints as to what the problem is. So, what EXACTLY does that compiler error say?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!