• 2022-06-07
    下面哪个程序变量age的定义是正确的()
    A: public class Employee{ public void show(){ System.out.println(age); } public int age; }
    B: public class Employee{ public void show(){ System.out.println(age); int age = 20; } }
    C: public class Employee{ public void show(){ System.out.println(age); } }
  • A

    举一反三

    内容

    • 0

      阅读下列的程序 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"); } } A. B. C. D.

    • 1

      下列程序运行结果是 public class Demo { public static void main(String[] args) { Object obj=new Father(){ public void show(){ System.out.println("helloworld"); } }; obj.show(); } } class Father{ public void show(){ System.out.println("hello father"); } }

    • 2

      下列程序运行结果是(  ) public class Demo {     public static void main(String[] args) {         Object obj=new Father(){             public void show(){                 System.out.println("helloworld");             }         };         obj.show();     } } class Father{     public void show(){         System.out.println("hello father");     } }

    • 3

      在C#中,下列结构或者类定义正确的是(选一项) A: public struct Person{ string name; int age; public void ShowName(){ Console.WriteLine(name); }} B: public struct Person{ string name; int age; public Person(){ Conssole.WriteLine(name); }} C: public class Person{ string name; int age; public Person(){ Conssole.WriteLine(name); }} D: public class Person{ string name; int age; public Person(string name){ Conssole.WriteLine(name); }}

    • 4

      请阅读下面的程序,写出最终的结果: interface Inter { public void show(); } abstract class AbstractInter implements Inter { public void show() { System.out.println("AbstractInter show()"); } } class InterImpl extends AbstractInter { public void show() { System.out.println("InterImpl show()"); } } public class InterImplTest { public static void main(String[] args) { InterImpl i = new InterImpl(); i. show(); } }