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...


diff between abstract methods and interfaces with programing
(code) example?

Answers were Sorted based on User's Feedback



diff between abstract methods and interfaces with programing (code) example?..

Answer / naresh p

an abstract class contains the concrete methods as well
abstract methods. It may instance variables and static
final variables
an interface contains only abstract methods. all the
variables are by default static and final.
an abstract class contains constructor where as an
interface does not have constructors...

Is This Answer Correct ?    1 Yes 0 No

diff between abstract methods and interfaces with programing (code) example?..

Answer / karthik

abstract class A
{
protected abstract void show();
}

public class xx extends A
{
protected void show()
{
System.out.println("karthik ok");

}

static void main(String aa[])
{
xx ob=new xx();
ob.show();
}
}


But in Interface


interface A
{
protected abstract void show();
}



public class xx implements A
{
protected void show()
{
System.out.println("karthik ok");

}

static void main(String aa[])
{
xx ob=new xx();
ob.show();
}
}

modifier protected not allowed here
protected abstract void show(); in Interface
Because Default public method


But in Abstract class we can have protected


interface A
{
int x;//Error we should need initial value
}

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More Core Java Interview Questions

What is class and object in java?

0 Answers  


What are basic keywords?

0 Answers  


How many types of equations are there?

0 Answers  


How do you create a reference in java?

0 Answers  


What ide should I use for java?

0 Answers  


What is array sorting in java?

0 Answers  


What is the use of singleton class?

0 Answers  


What is a newline character in java?

0 Answers  


How many objects are created when we create String class object using new operator?

9 Answers   Mind Tree,


What happens if we override only equals?

0 Answers  


What is the full meaning of java?

0 Answers  


Which keyword specify that a variable is effectively final ?

0 Answers  


Categories