In below code what is difference between obj1 & obj2 ? My question is in syntax -
Classname1 objectname = new Classname2();
May be Classname1=Classname2
what is significance of Classname1
.
// Superclass
class Base {
public static void display() {
System.out.println("Static or class method from Base");
}
}
// Subclass
class Derived extends Base {
public void print() {
System.out.println("Non-static or Instance method from Derived");
}
}
public class Test {
public static void main(String args[ ]) {
Base obj1 = new Derived();
Derived obj2 = new Derived();
}
}