Originally posted by ramya sri:
How can a construcor declared that it throws Exception,wat is the use of the declaration, the block that uses constructor must be enclosed in "TRY" or not. and wat about the inherited class construtor(the Question is some what ambiguous)
Originally posted by Mark Uppeteer:
source: Me
Hi guys, this was something I found on my 'to try' pages. No big surprises here but it shows the inner class can save the outer class from the evil gc.
regards,
Mark
Originally posted by Keith Lynn:
The reason is that subclasses can implements interfaces that are not implemented by their superclasses.
If you have a non-final class, A, which does not implement an interface, B, it is possible that a reference of type A actually refers to an object created from a subclass of A which does implement B. So for this reason, casts at compile-time are allowed.
However, if class A is final, then it cannot have subclasses.
Originally posted by Keith Lynn:
However, at compile-time a cast to an interface type is always allowed except in the case where the runtime type of the RelationalExpression is a final class.
Produces the following error:
test.java:16: inconvertible types
found : B
required: I1
i=(I1)b;
^
test.java:17: inconvertible types
found : B
required: I1
System.out.println(b instanceof I1);
^
2 errors
Originally posted by Aniruddha Jadhao:
Hi
I have one confusion for instace of oprator .
Instance of operator chks the reference to the hirarchy of the class on Right side otherwise der will be compiler error right?.
if we tak an e.g HashMap o1 = new HashMap();
System.ot.print("tru/false-->"01 instanceof Collection);
Now when i ran the code , it complied successfully & prints false.
but my Q? is as Collection interface nither extended/implementd by any of the ansecstors of Map how this program can run w/out cimplier error?
thanks
aniruddha
Originally posted by sentil kumar:
class outer {
void show() {
final int a =1;
int b =12;
class minner extends outer{
public void show1(){
System.out.println("method--"+a);
}
}
}
b can not be accessed by minner class. because a will be exist in stack.
but we can access the a ,where the final variable a will be stored.