Skip to content

Instantly share code, notes, and snippets.

@P0huber
Created November 18, 2017 16:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save P0huber/620ce34608c219f18f6b36b85a67cef6 to your computer and use it in GitHub Desktop.
Save P0huber/620ce34608c219f18f6b36b85a67cef6 to your computer and use it in GitHub Desktop.
Practice of using abstract classes. Практика использования абстрактных классов [Java]
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