File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Package

 
rex tony
Ranch Hand
Posts: 159
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. package test1;
2. public class Test1 {
3. static int x = 42;
4. }
1. package test2;
2. public class Test2 extends test1.Test1 {
3. public static void main(String[] args) {
4. System.out.println("x = " + x);
5. }
6. }
Compilation fails because of an error in line 2 of class Test2.
or
Compilation fails because of an error in line 4 of class Test2.
regards
Rex
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try it out? What do you think yourself? What's exactly your question about this?
 
rex tony
Ranch Hand
Posts: 159
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If we excute both package,the program will get complier time exception.
I think the compiler exception will come to line4 from the package2.
Is it correct.
But they told the compiler exception come to line2 from the package2
I hope that you'll get my question
regards
rex
 
P Ventura
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please, don't use the term exception for compilation fail.

I tried to compile the example and the result was a compilation fail at line 4
as I supposed (variable is not visible).
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic