Home Java Programming Language / Programs / If you inherit an abstract class, you have to provide implementations to all the abstract methods in it.
🚀 Programming Example

If you inherit an abstract class, you have to provide implementations to all the abstract methods in it.

👁 929 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

<code><font  size=2 face="Courier New"><font color="#0066CC"><b>abstract </b></font><font color="#FF0000"><b>class </b></font><font color="#0066CC"><b>Parent</b></font><b>{
  </b><font color="#0066CC"><b>abstract </b></font><font color="#800000"><b>void </b></font><font color="#0066CC"><b>mother</b></font><b>();
  </b><font color="#0066CC"><b>abstract </b></font><font color="#800000"><b>void </b></font><font color="#0066CC"><b>father</b></font><b>();
}
</b><font color="#FF0000"><b>class </b></font><font color="#0066CC"><b>Child extends Parent</b></font><b>{
	</b><font color="#800000"><b>void </b></font><font color="#0066CC"><b>mother</b></font><b>(){
		</b><font color="#0066CC"><b>System</b></font><b>.</b><font color="#0066CC"><b>out</b></font><b>.</b><font color="#0066CC"><b>println</b></font><b>(&quot;I am Your Mother&quot;);
		}

	</b><font color="#800000"><b>void </b></font><font color="#0066CC"><b>father</b></font><b>(){
				</b><font color="#0066CC"><b>System</b></font><b>.</b><font color="#0066CC"><b>out</b></font><b>.</b><font color="#0066CC"><b>println</b></font><b>(&quot;I am Your father&quot;);
		}
	</b><font color="#FF0000"><b>public </b></font><font color="#800000"><b>static void </b></font><font color="#0066CC"><b>main</b></font><b>(</b><font color="#0066CC"><b>String args</b></font><b>[]){
	 </b><font color="#0066CC"><b>Parent obj1 </b></font><b>= </b><font color="#FF0000"><b>new </b></font><font color="#0066CC"><b>Child</b></font><b>();
	 </b><font color="#0066CC"><b>obj1</b></font><b>.</b><font color="#0066CC"><b>mother</b></font><b>();

	 </b><font color="#0066CC"><b>Parent obj2 </b></font><b>= </b><font color="#FF0000"><b>new </b></font><font color="#0066CC"><b>Child</b></font><b>();
	 </b><font color="#0066CC"><b>obj1</b></font><b>.</b><font color="#0066CC"><b>father</b></font><b>();
	}
}
</b></font>
</code>
                        

🖥 Program Output

I am Your Mother
I am Your father
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.