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?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

Can you tell me range of byte?

955


Write a program to reverse a number in java?

1057


Does java linked list allow duplicates?

928


What is == and === in javascript?

1013


In the below example, what will be the output?

992


What is meant by method?

1038


Discuss different types of errors that generally occur while programming.

992


What is computer compiler?

953


What is stack explain?

947


What is static import?

1117


What is the difference between serial and throughput garbage collector?

1051


Difference between string, stringbuffer and stringbuilder?

994


What is a priority queue java?

950


Can we have a method name same as class name in java?

1009


How can you handle java exceptions?

980