OCJP

Partial Implementation in Java

When any class extends the Parent class or implement any interface then the child class must override all the abstract methods of Parent class or interface. But if child class does not override all the methods then it must be declared as abstract class and all the child of Child class (Multilevel) must override remaining methods.

package jdbcdemo1;

interface Study{
	void theory();
	void practical();
}

abstract class Room implements Study{
	
	@Override
	public void theory() {
		System.out.println("Theory Work in Class Room");
	}
}

class Lab extends Room{
	
	@Override
	public void practical() {
		System.out.println("Practical Work in Lab");
		
	}
}
public class PartialImplementDemo{

	public static void main(String []a) {
		
		Lab L= new Lab();
		L.theory();
		L.practical();
	}
}

Output will be like

Theory Work in Class Room
Practical Work in Lab

Leave a Reply

Your email address will not be published. Required fields are marked *


× How can I help you?