class - Interfaces: Java Language Specification -


jls java se 7 : 9.2 please explain:

  1. 3rd bullet point
  2. 5th line (in bold)
  3. 2nd last line

every class in java implicitly (or explicitly) sub type of java.lang.object.

the class object superclass (§8.1.4) of other classes.

because of this, can invoke method declared in object on variable of class type.

string var = ...; var.hashcode(); 

this has true interface type variables well

someinterface var = ...; var.hashcode(); 

for reason, interface must implicitly declare (as abstract) methods declared in java.lang.object.

you can't override final methods, interface declares methods must implemented in sub types, compile time error thrown if interface declares method declared final in java.lang.object.

an interface can declare classes, interfaces, , fields in body. if sub interface declares of same name, hiding those. therefore doesn't inherit them.

for example,

public static void main(string[] args) throws exception {     system.out.println(parent.answer);     system.out.println(child.answer); }  interface parent {     int answer = 42; }  interface child extends parent {     int answer = 0; } 

prints

42 0 

there no way parent's value child reference.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -