Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what is abstractclass ? what is ab

Status
Not open for further replies.

elanja

Programmer
Sep 10, 2003
13
0
0
IN
what is abstractclass ?
what is abstract Interface ?
Differentiate abstractclass and Interface

By
Raj
 
Abstract class can have one abstract method at miminum.
All methods in Interface should be abstract, so user has to implement all methods when he implements an interace.

here is my example
------
//test.java
class test
{
public static void main(String args[])
{
human Peter = new human();
Peter.playingRPG();
}
}
------
//human.java
class human extends hominoidea implements playingComputer
{
void eating()
{
System.out.println("Use spoon or chopstick to eat");
}
public void icq()
{
System.out.println("start icq");
System.out.println("Find who is online");
System.out.println("chat with your friend");
}
public void playingRPG()
{
System.out.println("start the game");
System.out.println("Load a save");
System.out.println("go to a town");
}
}
------
//playingComputer.java
public interface playingComputer
{
public abstract void icq(); // abstract can be omitted here because method is supposed to be abstract in interface
public void playingRPG();
}
------
//hominoidea.java
abstract class hominoidea
{
void walkWithFourLeg()
{
System.out.println("walking");
}
abstract void eating();
}
------
 
Why some of these questions sound like uni/college asignments questions from students that can not be bother to look up the answer? Any introductory Java book would have provided an answer to question on this thread!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top