File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Package Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Package" Watch "Package" New topic
Author

Package

rex tony
Ranch Hand

Joined: Aug 29, 2007
Posts: 159
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

Joined: Aug 16, 2005
Posts: 13868
    
  10

Did you try it out? What do you think yourself? What's exactly your question about this?


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
rex tony
Ranch Hand

Joined: Aug 29, 2007
Posts: 159
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

Joined: Jan 24, 2007
Posts: 42
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).


Objective: SCJP 1.5<br /><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html" target="_blank" rel="nofollow">API</a><br /> <blockquote><font size="1" face="Verdana, Arial">code:</font><hr><pre><font size="2"><br />Double n1 = Double.NaN; Double n2 = Double.NaN;<br /> n1.equals(n2) // true even though Double.NaN != Double.NaN<br />-0.0 == +0.0; // true<br />Double n1 = -0.0;Double n2 = +0.0;<br />n1.equals(n2) // false even though -0.0 == +0.0<br /></font></pre><hr></blockquote>
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Package
 
Similar Threads
package
Compilation fails
Package level question.
error in result
Mock Exam Qn.(What is the result)