Joke Collection Website - Blessing messages - How to write Java short message interface

How to write Java short message interface

Hello, I'm glad to answer your question:

First, define the interface: two mobile methods (calling and sending messages).

Public interface mobile device (

Public void call ();

public void sendMessage();

}

Then define the abstract class pad to realize the mobile interface (because the tablet computer has the function of a mobile phone).

The public abstract class Pad realizes mobile (

//Implement the called function.

Public void call () {

System.out.println ("made a phone call");

}

//What about the text message?

Public void sendMessage(){

System.out.println ("short message sent");

}

//Add a virtual method of surfing the Internet.

Public abstract void network ();

//Add virtual methods to play games.

Public abstract void playgame ();

}

//The real tablet computer (Ipad) inherits all the functions of pad and realizes online games.

Public Ipad expansion board (

@ Overlay

Public void network () {

System.out.println ("online and offline");

}

@ Overlay

Public void play game(){

System.out.println ("played a game");

}

}

The code above, where Mobile is the interface. Pad is an abstract class, and the following are polymorphic:

Public static void main(String[] args) {

Pad pad = new iPad ();

pad . network();

}

I hope my answer can help the landlord! thank you