Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ParentClass {
- public void parentMethod() {
- System.out.println("This is parent class");
- }
- }
- class ChildClass extends ParentClass {
- public void childMethod() {
- System.out.println("This is child class");
- }
- }
- public class Main {
- public static void main(String[] args) {
- ParentClass parentObject = new ParentClass();
- ChildClass childObject = new ChildClass();
- parentObject.parentMethod();
- childObject.childMethod();
- childObject.parentMethod();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement