suppose we have an interface & that interface contains five
methods. if a class implements that interface then we have
to bound that to give tha definition of all five methods in
that class. If we declare that class as abstract then can
we call only two methods to give the deinition of that
method & i don't want to give the definition of all the
methods? can it possible
Answer Posted / sitaram
yes it is possible, just make rest of the method abstract
explicitly.
public interface InterfaceSample {
public void method1();
public void method2();
public void method3();
public void method4();
}
abstract class Abstclass implements InterfaceSample{
public abstract void method1();
public abstract void method2();
public void method3(){
System.out.println(" astract method3 ..............");
}
}
public class Sample extends Abstclass {
public void method1(){
System.out.println("method1 ..............");
}
public void method2(){
System.out.println("method2 ..............");
}
public void method4(){
System.out.println("method4 ..............");
}
public static void main(String[] args) {
Sample s1 = new Sample();
s1.method1();
s1.method2();
s1.method3();
s1.method4();
}
}
| Is This Answer Correct ? | 0 Yes | 2 No |
Post New Answer View All Answers
Is age discrete or continuous?
What are methods of a class?
What is the unit of plancks constant?
What is indexof in java?
What is a numeric digit?
What is :: operator in java 8?
What do you understand by copy constructor in java?
Give an example of use of pointers in java class.
What is overloading and overriding in java?
How do you define a set in java?
Write a java program to find the route that connects between Red and Green Cells. General Rules for traversal 1. You can traverse from one cell to another vertically, horizontally or diagonally. 2. You cannot traverse through Black cells. 3. There should be only one Red and Green cell and at least one of each should be present. Otherwise the array is invalid. 4. You cannot revisit a cell that you have already traversed. 5. The maze need not be in the same as given in the above example
What flag up means?
What is the advantage of functional interface in java 8?
Can we sort a map in java?
What is java and its types?