From 09a0661ccb604fb6ae15e40128cfaf7f75071260 Mon Sep 17 00:00:00 2001 From: Jeffin G Benny <69665999+JeffinGBenny@users.noreply.github.com> Date: Fri, 29 Oct 2021 08:42:51 +0530 Subject: [PATCH] Add files via upload --- Main.java | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Main.java diff --git a/Main.java b/Main.java new file mode 100644 index 0000000..9281447 --- /dev/null +++ b/Main.java @@ -0,0 +1,23 @@ +class Parent { + void parentMethod(){ + System.out.println("This is parent class"); + + } +} + class Child extends Parent{ + void childMethod(){ + System.out.println("This is child class"); + } + + +} +public class Main +{public static void main(String[] args) { + Parent p= new Parent(); + Child c= new Child(); + p.parentMethod(); //method of parent by object of parent + + c.childMethod();//method of child class by object of child class + c.parentMethod();//method of parent class by object of child class + } +} \ No newline at end of file