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() } }
内容
- 0
以下代码调试结果 class Base {} class Sub extends Base {} public class CEx{ public static void main(String argv[]){ Base b = new Base(); Sub s = (Sub) b; } }
- 1
public class E4_1{ public static void main(String args[]) { int a = 1; int b = 2; int c = 3; a += 5; b *= 4; c += a * b; c %= 6; System.out.println("a = " + a); //代码1 System.out.println("b = " + b); //代码2 System.out.println("c = " + c); //代码3 }}运行结果,代码1______ ,代码2______ ,代码3______ 。
- 2
阅读以下程序,请写出代码1和代码2的运行结果 public class App3_1{ public static void main(String args[]) { int a=155; float b=20.0f; System.out.println("a="+a+",b="+b); //代码1 System.out.println("a/b="+(a/b)); //代码2 } }
- 3
>>>x = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]>>>x.index(2) 语句运行结果正确的是( )。 A: 1 B: 2 C: 3 D: 4
- 4
下列标注行中,( )行代码有错。 interface Com{ int MAX=100; //1 void f(); } abstract class Animal implements Com{ int MIN; //2 } class Dog extends Animal{ public void f(){ MIN=10; //3 MAX=200; //4 } } A: 1 B: 2 C: 3 D: 4