若有如下程序:
public class Test {
public static void main (String[] args) {
int x=20;
if (x>10) System.out.print(x-=5);
if (x>5) System.out.print(x--);
}
}则程序运行后的输出结果是【 】。
第1题:
若有以下程序: #include <iostream> using namespace std; class Base { public: Base () { x=0; } int x; }; class Derived1 : virtual public Base { public: Derived1 () { x=10; } }; class Derived2 : virtual public Base { public: Derived2 () { x=20; } }; class Derived : public Derived1,protected Derived2{ }; int main() { Derived obi; cout<<obj.x<<endl; return 0; } 该程序运行后的输出结果是
A.20
B.30
C.10
D.0
第2题:
若有以下程序: #include<iostream> using namespace Std; Class Base {public: Base() {x=0;} int x;}; class Derivedl:virtua1 public Base {public: Derived1() {x=10;}}; class Derived2:virtual1 public Base {public: Derived2()
A.20
B.30
C.10
D.0
第3题:
第4题:
若有以下程序: #include <iostream> using namespace std; class Base { public: Base() { x=0; } int x; }; class Derivedl : virtual public Base { public: Derivedl() { x=10; } }; class Derived2 : virtual public Base { public: Derived2() { x=20; } }; class Derived : public Derivedl,protected Derived2 { }; int main () { Derived obj; cout<<obj.x<<end1; return 0; } 该程序运行后的输出结果是( )。
A.10
B.20
C.30
D.0
第5题: