• 2022-06-08
    abstract class BaseClass { public virtual void MethodA() { } public virtual void MethodB() { } } class Class1: BaseClass { public void MethodA(string arg){ } public override void MethodB(){ } } class Class2: Class1 { new public void MethodB(){ } } class MainClass { public static void Main(string[] args) { Class2 o = new Class2(); Console.WriteLine(o.MethodA()); } } 请问,o.MethodA调用的是
    A: BaseClass.MethodA
    B: Class2.MethodA
    C: Class1.MethodA
    D: 都不是
  • A

    内容

    • 0

      智慧职教: public class Something { public static void main(String[] args) { Other o = new Other(); new Something().addOne(o); } public void addOne(final Other o) { o.i ; } } class Other { public int i; }

    • 1

      public class Example {     public static void main(String[] args) {         new Father () {             public void show() {                 System.out.println("helloworld");             }         }.show();     } } class Father {     public void show() {         System.out.println("hellofather");     } }

    • 2

      从下面四段代码中选择出正确的代码段() A: public class Something {public static void main(String[] args) {Other o = new Other();new Something().addOne(o);}public void addOne(final Other o) {o.i++;}}class Other {public int i;} B: public class Something {void doSomething () {private String s = ̶”;int l = s.length();}} C: abstract class Name {private String name;public abstract boolean isStupidName(String name) {}} D: public class Something {public int addOne(final int x) {return ++x; }}

    • 3

      Which two allow the class Thing to be instantiated using new Thing()? A:  public class Thing { } B:  public class Thing { public Thing() {} } C:  public class Thing { public Thing(void) {} } D:  public class Thing { public Thing(String s) {} } E:  public class Thing { public void Thing() {} public Thing(String s) {} }

    • 4

      import java.io.IOException;  public class ExceptionTest(  public static void main (String[]args)  try (  methodA();  ) catch (IOException e)  (  system.out.printIn(“Caught IOException”);  ) catch (Exception e)   (  system.out.printIn(“Caught Exception”);  )  )  public void methodA ()   {  throw new IOException ();  }   What is the result?() A:  The code will not compile. B:  The output is caught exception. C:  The output is caught IOException. D:  The program executes normally without printing a message.