| |

VerySource

 Forgot password?
 Register
Search
View: 1924|Reply: 12

Please take a look at the beginner's question, thank you for answering, I will remember

[Copy link]

2

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-25 11:00:01
| Show all posts |Read mode
Has a base class class T {
 void sleep () {System.out.println ("aaa");}
}
Has an interface interface I {

}
There is a class class Test extends T
{
  void sleep () () /// Override the sleep method of the base class
}

What I want to do now is that if Test wants to override the sleep method of the base class, then I must implement the I interface. If I do n’t implement it, I will report an error. interface
Reply

Use magic Report

1

Threads

11

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-2-13 13:45:01
| Show all posts
What does it have to do with the I interface?
Reply

Use magic Report

1

Threads

21

Posts

19.00

Credits

Newbie

Rank: 1

Credits
19.00

 Australia

Post time: 2020-2-13 20:00:01
| Show all posts
interface I {
    public void mustImpl ();
}

abstract class AbstractTest extends T implements i {
      
}

class test extends AbstractTest {
   // do something

}
Reply

Use magic Report

0

Threads

14

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 Invalid IP Address

Post time: 2020-2-15 20:15:02
| Show all posts
Why has to be this way? If so, what are the goals? Strange.
Reply

Use magic Report

0

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-2-21 18:30:02
| Show all posts
I do not quite understand you!
Reply

Use magic Report

0

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-3-2 10:30:01
| Show all posts
class Test extends T
{
  void sleep () {
    if ((this instanceOf I) == false) {
         throw new RuntimeException ("must implement I");
    }


}
Don't know if you mean it


}
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-3-15 10:15:01
| Show all posts
class T interface I {
 void sleep () {System.out.println ("aaa");}
}
interface I {

}
class Test extends T
{
  void sleep () {}
}
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-3-19 11:00:01
| Show all posts
Subclasses inherit parent classes and interfaces
Reply

Use magic Report

0

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-4-18 13:00:01
| Show all posts
shen me dongdong a?
Reply

Use magic Report

0

Threads

3

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-4-25 17:45:01
| Show all posts
Don't understand what it means?
public class Test extends T {
    void sleep () {}
    public static void main (String [] args) {
        new Test (). sleep ();
    }
}

class T {
 void sleep () {System.out.println ("aaa");}
}
interface I {
}
No results are printed, rewriting is ok
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list