Created
November 18, 2017 16:11
-
-
Save P0huber/620ce34608c219f18f6b36b85a67cef6 to your computer and use it in GitHub Desktop.
Practice of using abstract classes. Практика использования абстрактных классов [Java]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AbstractWork { | |
public static void main(String[] args) {} | |
public static abstract class Animal { // is subclassed by class Cow | |
public abstract String getName();} // is implemented in class Cow | |
public static class Cow extends Animal{ // class inheritance occurs | |
public String getName(){ | |
return "I`m a cow Marry almost :)";} // the implementation occurs | |
} | |
} | |
/*Корова — тоже животное | |
Унаследуй класс Cow от Animal. | |
Реализуй все недостающие методы в классе Cow. | |
Требования: | |
1. Класс Animal должен быть абстрактным. | |
2. Класс Cow не должен быть абстрактным. | |
3. Класс Cow должен наследоваться от класса Animal. | |
4. Класс Cow должен реализовать абстрактный метод из класса Animal. | |
5. Метод getName() класса Cow должен возвращать любое имя коровы.*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment