【单选题】假设有如下接口: public interface swim { void swim(); void breathe(); } public interface walk { void walk(); void breathe(); } 下面那些类的实现是正确的
A.
class Frog: swim,walk { void swim() { Console.WriteLine("I can swim"); } void walk() { Console.WriteLine("I can walk"); } void swim.breathe() { Console.WriteLine("I can breathe while swiming"); } void walk.breathe() { Console.WriteLine("I can breathe while walking"); } }
B.
class Fish : swim { public void swim() { Console.WriteLine("I can swim"); } public void swim.breathe() { Console.WriteLine("I can breathe while swiming"); } }
C.
class Fish : swim { public void swim() { Console.WriteLine("I can swim"); } public void breathe() { Console.WriteLine("I can breathe while swiming"); } }
D.
class Frog: swim,walk { public void swim() { Console.WriteLine("I can swim"); } public void walk() { Console.WriteLine("I can walk"); } void swim.breathe() { Console.WriteLine("I can breathe while swiming"); } void breathe() { Console.WriteLine("I can breathe while walking"); } }
【简答题】intece A{ int x = 0 } class B{ int x =1 } class C extends B implements A { public void pX(){ System.out.println(x) } public static void main(String[] args) { new C().pX() } }