Skip to content

Commit

Permalink
abstract class/methods demo: parent class holding abstract method
Browse files Browse the repository at this point in the history
  • Loading branch information
NirmalSilwal committed Sep 4, 2020
1 parent 6bd1aa5 commit 518c282
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions CodingBlocks Training/Day16/parentAbstract.java
Original file line number Diff line number Diff line change
@@ -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");
}
}

0 comments on commit 518c282

Please sign in to comment.