From 155205edc73eb9e1340b74392ecb497e50208e3e Mon Sep 17 00:00:00 2001 From: Vishwajeet-29-pro Date: Fri, 20 Dec 2024 07:43:34 +0530 Subject: [PATCH] feat: Add example method overriding --- .../org/practice/dsa/asked_in_interview/A.java | 7 +++++++ .../org/practice/dsa/asked_in_interview/B.java | 9 +++++++++ .../org/practice/dsa/asked_in_interview/C.java | 18 ++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 JavaDsaWithTest/src/main/java/org/practice/dsa/asked_in_interview/A.java create mode 100644 JavaDsaWithTest/src/main/java/org/practice/dsa/asked_in_interview/B.java create mode 100644 JavaDsaWithTest/src/main/java/org/practice/dsa/asked_in_interview/C.java diff --git a/JavaDsaWithTest/src/main/java/org/practice/dsa/asked_in_interview/A.java b/JavaDsaWithTest/src/main/java/org/practice/dsa/asked_in_interview/A.java new file mode 100644 index 00000000..6946e0b4 --- /dev/null +++ b/JavaDsaWithTest/src/main/java/org/practice/dsa/asked_in_interview/A.java @@ -0,0 +1,7 @@ +package org.practice.dsa.asked_in_interview; + +public class A { + public void printMethod() { + System.out.println("A"); + } +} diff --git a/JavaDsaWithTest/src/main/java/org/practice/dsa/asked_in_interview/B.java b/JavaDsaWithTest/src/main/java/org/practice/dsa/asked_in_interview/B.java new file mode 100644 index 00000000..96796b8f --- /dev/null +++ b/JavaDsaWithTest/src/main/java/org/practice/dsa/asked_in_interview/B.java @@ -0,0 +1,9 @@ +package org.practice.dsa.asked_in_interview; + +public class B extends A{ + @Override + public void printMethod() { + super.printMethod(); + System.out.println("B"); + } +} diff --git a/JavaDsaWithTest/src/main/java/org/practice/dsa/asked_in_interview/C.java b/JavaDsaWithTest/src/main/java/org/practice/dsa/asked_in_interview/C.java new file mode 100644 index 00000000..a5938d90 --- /dev/null +++ b/JavaDsaWithTest/src/main/java/org/practice/dsa/asked_in_interview/C.java @@ -0,0 +1,18 @@ +package org.practice.dsa.asked_in_interview; + +import java.util.UUID; + +public class C extends B{ + @Override + public void printMethod() { + super.printMethod(); + System.out.println("C"); + } + + public static void main(String[] args) { + C c = new C(); + c.printMethod(); + UUID uuid = UUID.randomUUID(); + System.out.println(uuid); + } +}