Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abstract Classes and Methods #35

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions 5. Classes/Abs.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

/*
* Abs is a sub class of Sup class and the super class for SubAbs class
*/
abstract class Abs extends Sup{
abstract void printSomething();
}
3 changes: 3 additions & 0 deletions 5. Classes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Abstract Classes and Abstract methods

Created a class Sup, that has a method print() which prints 'I am super', then create a Abs subclass which has an abstract method, printSomething(). Then create another subclass of Abs and override the method to print 'My super class is Abs'.
11 changes: 11 additions & 0 deletions 5. Classes/SubAbs.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* SubAbs is the subclass of Abs class
*/
public class SubAbs extends Abs{

@Override
void printSomething() {
System.out.println("");
}

}
8 changes: 8 additions & 0 deletions 5. Classes/Sup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Sup is the supper class of Abs class and indirectly the highest super class of SubAbs class
*/
public class Sup {
void print(){
System.out.println("I am Super");
}
}