Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main{
- public static void main(String[] args){
- General gen = new General();
- System.out.println(gen.currentDate());
- System.out.println(gen.name());
- System.out.println(gen.doMath());
- General gen2 = new Specification();
- System.out.println(gen2.currentDate());
- System.out.println(gen2.name());
- System.out.println(gen2.doMath());
- }
- }
- class General{
- Date currentDate(){
- return new Date;
- }
- String name(){
- return "Вася";
- }
- double doMath(){
- return 2+2;
- }
- }
- class Specification extends General{
- String name(){
- return "Петя";
- }
- double doMath(){
- return Math.PI;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement