Skip to content

Instantly share code, notes, and snippets.

@bhavin192
Last active August 2, 2016 09:52
Show Gist options
  • Save bhavin192/b126b93bdd31d2ff483c4d5f6e46ac09 to your computer and use it in GitHub Desktop.
Save bhavin192/b126b93bdd31d2ff483c4d5f6e46ac09 to your computer and use it in GitHub Desktop.
class Main2{
public static void main(String args[]){
base obj = new der();
obj.myMethod();
obj.myNewMethod();
}
}
class base{
public void myMethod(){
System.out.println("Method from Base");
}
}
class der extends base{
public void myNewMethod(){
System.out.println("Method from Der");
}
}
/*
///////////////////////////////
D:\inp>javac Main2.java
Main2.java:5: error: cannot find symbol
obj.myNewMethod();
^
symbol: method myNewMethod()
location: variable obj of type base
1 error
////////////////////////////////////
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment