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();
}
}
I am Rahim, My Favourite color is Green
Press any key to continue . . .
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.
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.