Henry Wong wrote:
Lukas Sieradzki wrote:interface's methods are implicitly:
public abstract
interface's variables are implicitly:
public static final
You cannot change it.
Interesting points... but this topic is not about interfaces.
Henry
Ben Zaidi wrote:Hi,
In K&B book page 104, chapter, an example in exam watch is givenclass Animal {
public void eat() throws Exception {
// throws an Exception
}
}
class Dog2 extends Animal {
public void eat() { // no Exceptions }
public static void main(String [] args) {
Animal a = new Dog2();
Dog2 d = new Dog2();
d.eat(); // ok
a.eat(); // compiler error -
// unreported exception
}
}
I have a query, why the compiler is looking at the Dog verison of eat method. Though at compile time,
compiler sees the reference type rather then actual object type. Then why it is saying unhandled exception,
though it must see the animal version of the eat method, which is handling the exception
Akanksha Joy wrote:
The code is taken from the K&B book page 62 chapter1 (latest edition). There are many ways to declare an enum. The above is one the way i.e inside a class. But its not working. There's error in compiling. I think the enclosing class name is required...it's as if a nested class.......
jeetendra Choudhary wrote:I have Doubt on behavior of !=, == and equals method in following example from K&B. please some one explain little bit more about that. sorry for such stupid question.
Thanks In Advance.
Srikanth Nakka wrote:Polymorphism doesn't apply for static. this is not overriding but we can say Hiding