Forums Register Login

Package

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
Did you try it out? What do you think yourself? What's exactly your question about this?
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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).
They worship nothing. They say it's because nothing lasts forever. Like this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 667 times.
Similar Threads
Mock Exam Qn.(What is the result)
Package level question.
package
error in result
Compilation fails
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 07:40:19.