-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
abstract class/methods demo: parent class holding abstract method
- Loading branch information
1 parent
6bd1aa5
commit 518c282
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |