以下代码输出结果为()class A{ public $a = 1; protected $b = 2;}class B extends A{ public $b = 3; function __construct(){ echo $this->a+$this->b; }}$b = new B();
A: 1
B: 2
C: 3
D: 4
A: 1
B: 2
C: 3
D: 4
举一反三
- 阅读以下程序class A{protected: int a=0;public: A(){a=1;}};class B:virtual public A{public: B(){a++;}};class C:virtual public A{public: C(){a+=2;}};class D:public B,public C{public: void print(){ cout< A: 0 B: 1 C: 3 D: 4
- 说出下列B类中【代码1】,【代码2】的输出结果 class A { public int getNumber(int a) { return a+1; } } class B extends A { public int getNumber (int a) { return a+100; } public static void main (String args[]) { A a =new A(); System.out.println(a.getNumber(10)); //【代码1】 a = new B(); System.out.println(a.getNumber(10)); //【代码2】 } }
- 给出以下代码,请问该程序的运行结果是什么?( )class S1 {public static void main(String[] args) {new S2();}S1() {}}class S2 extends S1{S2() {System.out.print("S2");}}请选择一个正确答案:(1)S1(2)S2(3)S1S2(4)S1S2 A: 1 B: 2 C: 3 D: 4
- def f(): passprint(type(f()))以上代码输出结果为? A: <class 'function'> B: <class 'tuple'> C: <class 'NoneType'> D: <class 'str'>
- 定义类Block和类Demo,运行Demo的输出结果是。 class Block{ {//代码1 System.out.print("1"); } static{//代码2 System.out.print("2"); } {//代码3 System.out.print("3"); } public Block() {//代码4 System.out.print("4"); } static void show() {//代码5 System.out.print("5"); } static {//代码6 System.out.print("6"); } } //定义测试类Demo public class Demo { public static void main(String[] args) { new Block().show(); new Block() } }