Last active
August 2, 2016 09:52
-
-
Save bhavin192/b126b93bdd31d2ff483c4d5f6e46ac09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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