Joke Collection Website - Blessing messages - How to write Java short message interface
How to write Java short message interface
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
- Previous article:Mobile phone automatically cleans up spam messages.
- Next article:Can rural credit cooperatives receive short messages?
- Related articles
- Someone called me to help me find a job and asked me to contact each other. I texted him to contact me back in Shandong. What should I do?
- How to refund the order for the US group takeaway?
- Products and services of Guangzhou Pan Zhi Network Technology Co., Ltd.
- Simple and elegant birthday wishes for leaders
- Cell phone recording: find its location
- Is Jiaxing Express out of service?
- Donate materials to fight the epidemic.
- What was the result of the takeaway being stolen by the rider?
- How to set someone else's train for the ideal car? I have a message for you.
- Postgraduate entrance examination adjustment, information network received two re-examination notices at the same time, can both be admitted, and then go to participate in the re-examination of these