Home Java Programming Language / Programs / Understanding the important scenario of abstract class
🚀 Programming Example

Understanding the important scenario of abstract class

👁 1,100 Views
💻 Practical Program
📘 Step Learning
Learn this program step-by-step with algorithm, source code, output and detailed explanation.
No previous program
No next program

💻 Program Code


abstract class Favourite{
abstract void color();
}
//In real scenario, implementation is provided by others i.e. unknown by end user
class Ram extends Favourite{
	void color(){
		System.out.println("I am Ram, My Favourite color is Red");
		}
}

class Rahim extends Favourite{
	void color(){
		System.out.println("I am Rahim, My Favourite color is Green");
		}
}

//In real scenario, method is called by programmer or user
class Abstraction{
	public static void main(String args[]){
	Favourite s=new Rahim();//In real scenario, object is provided through method
	s.color();
	}
}
                        

🖥 Program Output

I am Rahim, My Favourite color is Green
Press any key to continue . . .
                            
No previous program
No next program
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.