filmov
tv
#java | Abstract Class | Telugu | Dr.Venkat | Polymorphism | Method Overriding | Interfaces | Python

Показать описание
Abstract Class:
Use of Abstract Methods and Concrete Methods
Link for Super and Sub class Relationship:
Link for Interfaces Concept:
-A class with minimum of one Abstract method (Method with no code).
-Objects cannot be created to an abstract class.
-Reference variables can be created
-Abstract classes can be extended.
-Abstract class provides an template for sub classes which can some common features to sub classes.
-Sub class has a responsibility to implement the abstract methods.
-When all the objects requirement is same we need to go for concrete methods(Methods with code) in an abstract class.
-When every object requirement is different we need to go for abstract methods.
---------------
//Manager
public abstract class Car
{
//Concrete Method
public void fuelTank()
{
}
//abstract methods
public abstract void steering();
public abstract void breaking();
}
//Team member1
public class Maruti extends Car
{
//Overriding the methods
public void steering()
{
}
public void breaking()
{
}
}
//Team member2
public class Santro extends Car
{
//Overriding the methods
public void steering()
{
}
public void breaking()
{
}
}
//main class
public class UseCar
{
public static void main(String args[])
{
Car c1 = new Maruti();
Car c2 = new Santro();
}
}
Use of Abstract Methods and Concrete Methods
Link for Super and Sub class Relationship:
Link for Interfaces Concept:
-A class with minimum of one Abstract method (Method with no code).
-Objects cannot be created to an abstract class.
-Reference variables can be created
-Abstract classes can be extended.
-Abstract class provides an template for sub classes which can some common features to sub classes.
-Sub class has a responsibility to implement the abstract methods.
-When all the objects requirement is same we need to go for concrete methods(Methods with code) in an abstract class.
-When every object requirement is different we need to go for abstract methods.
---------------
//Manager
public abstract class Car
{
//Concrete Method
public void fuelTank()
{
}
//abstract methods
public abstract void steering();
public abstract void breaking();
}
//Team member1
public class Maruti extends Car
{
//Overriding the methods
public void steering()
{
}
public void breaking()
{
}
}
//Team member2
public class Santro extends Car
{
//Overriding the methods
public void steering()
{
}
public void breaking()
{
}
}
//main class
public class UseCar
{
public static void main(String args[])
{
Car c1 = new Maruti();
Car c2 = new Santro();
}
}
Комментарии