From 518c28269e8f8d6b9bbea3ca39693c435a5d89ce Mon Sep 17 00:00:00 2001 From: NirmalSilwal Date: Fri, 4 Sep 2020 08:17:13 +0530 Subject: [PATCH] abstract class/methods demo: parent class holding abstract method --- .../Day16/parentAbstract.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 CodingBlocks Training/Day16/parentAbstract.java diff --git a/CodingBlocks Training/Day16/parentAbstract.java b/CodingBlocks Training/Day16/parentAbstract.java new file mode 100644 index 0000000..2597667 --- /dev/null +++ b/CodingBlocks Training/Day16/parentAbstract.java @@ -0,0 +1,26 @@ +package Lecture16; + +public abstract class parentAbstract { + + public int age = 10; + public static int num = 20; + + public void fun1() { + System.out.println("Inside parent fun1"); + } + +// public abstract void fun(); // error if class is not abstract + // The abstract method fun in type parentAbstract can only be defined by an abstract class + + public abstract void fun(); // abstract method + + // not allowed to have static abstract method +// public static abstract void funny(); + + // The abstract method funny in type parentAbstract can only set a + // visibility modifier, one of public or protected + + public void fun2() { + System.out.println("Inside parent fun2"); + } +}