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

Answers were Sorted based on User's Feedback



suppose we have an interface & that interface contains five methods. if a class implements tha..

Answer / nitin

yes it is possible, just make rest of the method abstract
explictly.

Example:
public interface Human {
public void canEat();
public void canThink();
public void canTalk();
public void canImegine();
public void canLove();

}
public abstract class Man implements Human {

public abstract void canEat();

public abstract void canImegine();
@Override
public abstract void canLove();

@Override
public void canTalk() {

}

@Override
public void canThink() {
}

}

public class Nitin extends Man{

/**
* @param args
*/
public static void main(String[] args) {
}

@Override
public void canEat() {

}

@Override
public void canImegine() {

}
@Override
public void canLove() {

}
}

Is This Answer Correct ?    29 Yes 1 No

suppose we have an interface & that interface contains five methods. if a class implements tha..

Answer / suresh chand

yes,it is possible that abstract class implements zero,
one,two,three or four interface methods but not all i.e
five. After this concrete class which extends the abstract
class, implements the remaining methods.

Is This Answer Correct ?    4 Yes 0 No

suppose we have an interface & that interface contains five methods. if a class implements tha..

Answer / sai hegde

It's possible that your abstract class implements one/all or
none of the interface methods. The concrete class that
extends your abstract class will have to provide
implementations for the methods that have not been
implemented in your abstract class.

Is This Answer Correct ?    1 Yes 2 No

suppose we have an interface & that interface contains five methods. if a class implements tha..

Answer / srini

i think we can accomplish by using adapter design pattern.

Is This Answer Correct ?    0 Yes 1 No

suppose we have an interface & that interface contains five methods. if a class implements tha..

Answer / 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

suppose we have an interface & that interface contains five methods. if a class implements tha..

Answer / pavan chaturvedi

no we have to override all methods of interface

Is This Answer Correct ?    2 Yes 20 No

Post New Answer

More Core Java Interview Questions

what is the form of storage space in java?

5 Answers  


Is oracle charging for java?

0 Answers  


What is the meaning of flag day?

0 Answers  


How many inner classes can a class have?

0 Answers  


How will you calculate the depth of a binary tree if the tree contains 15 nodes?

0 Answers   Aricent,


Why main() method is public, static and void in java ?

0 Answers  


What is super?

0 Answers  


why an outer class cannot be declared as private?

1 Answers  


Is it possible to cast an int value into a byte variable? What would happen if the value of int is larger than byte?

0 Answers  


Do we need to manually write Copy Constructor?

0 Answers   HCL,


What does it mean to flush a file?

0 Answers  


What do you mean by exception handling in Java?

0 Answers   Atos Origin,


Categories