gudii9
asked on
Base calss private
Hi,
I was going through following question from site
http://www.jchq.net/certkey/0102certkey.htm
Question 8)
What will happen when you attempt to compile and run this code?
private class Base{}
public class Vis{
transient int iVal;
public static void main(String elephant[]){
}
}
I have not understood the answer which says
Answer 8)1) Compile time error: Base cannot be private
A top level class such as base cannot be declared to be private.
we are not extending Base class right. Why still it complain.
please advise.
I was going through following question from site
http://www.jchq.net/certkey/0102certkey.htm
Question 8)
What will happen when you attempt to compile and run this code?
private class Base{}
public class Vis{
transient int iVal;
public static void main(String elephant[]){
}
}
I have not understood the answer which says
Answer 8)1) Compile time error: Base cannot be private
A top level class such as base cannot be declared to be private.
we are not extending Base class right. Why still it complain.
please advise.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The example class is a little misleading. A "top-level class" is different from a "base class." Top-level classes are those not nested inside other classes and, as objects mentioned above, cannot be private. This is because having a private top-level class would mean no other code could access it.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
>>> A "top-level class" is different from a "base class."
what is difference between base and top-level class. I do not see extend also in this example.
private class Base{}
is just simply sitting
what is difference between base and top-level class. I do not see extend also in this example.
private class Base{}
is just simply sitting
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.