问题和练习:继承

原文: https://docs.oracle.com/javase/tutorial/java/IandI/QandE/inherit-questions.html

问题

1.考虑以下两个类:

  1. public class ClassA {
  2. public void methodOne(int i) {
  3. }
  4. public void methodTwo(int i) {
  5. }
  6. public static void methodThree(int i) {
  7. }
  8. public static void methodFour(int i) {
  9. }
  10. }
  11. public class ClassB extends ClassA {
  12. public static void methodOne(int i) {
  13. }
  14. public void methodTwo(int i) {
  15. }
  16. public void methodThree(int i) {
  17. }
  18. public static void methodFour(int i) {
  19. }
  20. }

一个。哪个方法覆盖了超类中的方法? b。哪种方法隐藏了超类中的方法? c。其他方法有什么作用?

2.考虑你在问题和练习中写的 CardDeckDisplayDeck 类:课程。每个Object方法应该覆盖哪些类?

演习

1.编写您在问题 2 中回答的方法的实现。

检查你的答案。