Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
OCP Oracle Certified Professional Java SE 21 Developer (Exam 1Z0-830) Java SE 17 Developer (Exam 1Z0-829) Programmer’s Guide
this week in the
Programmer Certification
forum!
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Tim Cooke
Campbell Ritchie
paul wheaton
Ron McLeod
Devaka Cooray
Sheriffs:
Jeanne Boyarsky
Liutauras Vilda
Paul Clapham
Saloon Keepers:
Tim Holloway
Carey Brown
Piet Souris
Bartenders:
Forum:
Programmer Certification (OCPJP)
Question
vidya sagar
Ranch Hand
Posts: 580
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi friends
I came thru one question in mock exams
Given: 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. } What is the result? A. x = 0 B. x = 42 C. Compilation fails because of an error in line 2 of class Test2. D. Compilation fails because of an error in line 3 of class Test1. E. Compilation fails because of an error in line 4 of class Test2.
I hope the result will be option B
But they givan as C
Is i miss anything............plz confirm
vinuharan haran
Ranch Hand
Posts: 64
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
i think the answer should be 4.The variable x has package visibility.It cannot be accessed from another package.There is nothing wrong in line2 of class Test2.
[ April 26, 2005: Message edited by: vinuharan haran ]
vidya sagar
Ranch Hand
Posts: 580
posted 20 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
hi
Sorry once i posted i got a answer
Variable has default access so it not accessible outside the package
but answer given is C.........thats still confusing
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Mock Exam Qn.(What is the result)
Package level question.
package
error in result
Compilation fails
More...