Skip to content

Commit 31d6783

Browse files
committed
Abstract
1 parent 147b5e0 commit 31d6783

File tree

5 files changed

+35
-0
lines changed

5 files changed

+35
-0
lines changed

src/NandhuDSA/oops/Abstract/Abstract

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
• An abstract class in Java cannot be instantiated on its own; it is designed to be subclassed.
2+
3+
• Contains both abstract methods (without a body) and concrete methods (with a body).
4+
5+
• Provides a common base for subclasses, allowing them to share code.
6+
7+
• Enables subclasses to provide specific implementations for the abstract methods.

src/NandhuDSA/oops/Abstract/bike.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package NandhuDSA.oops.Abstract;
2+
3+
public class bike extends vehicle{
4+
void speed(){
5+
System.out.println("100km/h");
6+
}
7+
}

src/NandhuDSA/oops/Abstract/car.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package NandhuDSA.oops.Abstract;
2+
3+
public class car extends vehicle{
4+
void speed(){
5+
System.out.println("190km/h");
6+
}
7+
}

src/NandhuDSA/oops/Abstract/main.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package NandhuDSA.oops.Abstract;
2+
3+
public class main {
4+
public static void main(String[] args) {
5+
bike b1 = new bike();
6+
b1.speed();
7+
}
8+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package NandhuDSA.oops.Abstract;
2+
3+
public abstract class vehicle { // abstract method only in abstract class
4+
abstract void speed(); // this abstract class usage is all the child class override this abstract class
5+
}
6+

0 commit comments

Comments
 (0)