Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Why do we create threads in java?

1140


In java, what is the difference between method overloading and method overriding?

1047


What is the use of optional ?

980


Can a serialized object be transferred via network?

895


Who found java?

937


What are measurable parameters?

1012


Explain the importance of finally over return statement?

991


What is immutable data?

991


Does java linked list allow duplicates?

912


What's the purpose of static methods and static variables?

1032


Can we sort arraylist in java?

937


a thread is runnable, how does that work? : Java thread

925


What are the differences between heap and stack memory in java?

996


What is difference between c++ and java ?

1072


What are data structures in java?

914