[主观题]

写出程序的输出结果

class Class1 {

private string str = "Class1.str";

private int i = 0;

static void StringConvert(string str) {

str = "string being converted.";

}

static void StringConvert(Class1 c) {

c.str = "string being converted.";

}

static void Add(int i) {

i++;

}

static void AddWithRef(ref int i) {

i++;

}

static void Main() {

int i1 = 10;

int i2 = 20;

string str = "str";

C.lass1 c = new Class1();

A.dd(i1);

A.ddWithRef(ref i2);

A.dd(c.i);

StringConvert(str);

StringConvert(c);

C.onsole.WriteLine(i1);

C.onsole.WriteLine(i2);

C.onsole.WriteLine(c.i);

C.onsole.WriteLine(str);

C.onsole.WriteLine(c.str);

}

}

参考答案与解析:

相关试题

4 . 写出程序的输出结果class Class1 {private strin

[主观题]4 . 写出程序的输出结果class Class1 {private string str = "Class1.str";private int i = 0;static void StringConvert(string str) {str = "string being converted.";}static void StringConvert(Class1 c) {c.str = "string being converted.";}static void Add(int i

  • 查看答案
  • 写出程序的输出结果public abstract class A { publi

    [主观题]写出程序的输出结果public abstract class A{public A(){C.onsole.WriteLine('A');}public virtual void Fun(){C.onsole.WriteLine("A.Fun()");}}public class B: A{public B(){C.onsole.WriteLine('B');}public new void Fun(){C.onsole.WriteLine("B.Fun()");}public s

  • 查看答案
  • 写出程序的输出结果 public abstract class A {publi

    [主观题]写出程序的输出结果public abstract class A{public A(){C.onsole.WriteLine('A');}public virtual void Fun(){C.onsole.WriteLine("A.Fun()");}}public class B: A{public B(){C.onsole.WriteLine('B');}public new void Fun(){C.onsole.WriteLine("B.Fun()");}public s

  • 查看答案
  • 写出程序的输出结果:public class A { public virtua

    [主观题]写出程序的输出结果:public class A{public virtual void Fun1(int i){C.onsole.WriteLine(i);}public void Fun2(A a){a.Fun1(1);F.un1(5);}}public class B : A{public override void Fun1(int i){base.Fun1 (i + 1);}public static void Main(){B. b = new B();A. a = new A();

  • 查看答案
  • 以下程序的输出结果为()。public class Main {public s

    [单选题]以下程序的输出结果为( )。 public class Main { public static void main(String[] args) { int i=0, j=0, a=6; if((++i>0)||(++j>0)) a++; System.out.println( "i=" +i+", j ="+j+", a="+A; } }A.i=0, j=0, a=6B.i=1, j=1, a=7C.i=1, j=0, a=7D.i=0, j=1, a=7

  • 查看答案
  • 下面程序的结果为#includeint c;class A{private:in

    [单选题]下面程序的结果为includeint c;class A{private:int a;static int b;public:A( ){a下面程序的结果为 #include<iostream.h> int c; class A { private: int a; static int b; public: A( ) {a=0;c=0;} void seta( ){a++;} void setb( ){b++;}A.1 2 1B.1 2 2C.1 1 2D.2 2 2

  • 查看答案
  • 下面程序的结果为#includeint C;class A{ private:

    [单选题]下面程序的结果为includeint C;class A{ private: int a; static int b; public: A下面程序的结果为 #include<iostream.h> int C; class A { private: int a; static int b; public: A() {a=0;c=0;} void seta(){a++;} voidsetb(){b++;} voidsetc(){c++;} void display() {cout << a <<

  • 查看答案
  • 下面程序段的输出结果为public class MyClass{public s

    [单选题]下面程序段的输出结果为 public class MyClass { public static void main(String args[]) { String s="Helto! How are you?"; System.out.println(s.lastlndexOf("o",16)); } }A.16B.oC.uD.17

  • 查看答案
  • 下列程序的输出结果是 class Demo { void test( ) { S

    [单选题]下列程序的输出结果是 class Demo { void test( ) { Systeme.out.pnnt("NO");} void test(int i) { System.out.print(a);} void test(int a,int b) { System.out.print(a+b);} } class Test { public static void main(String args[ ] ) { Demo de=new Demo( ); de.test( ); de.

  • 查看答案
  • 下面程序的结果是 #include class test{private: in

    [单选题]下面程序的结果是 include class test{private: int num; publi下面程序的结果是 #include<iostream.h> class test{ private: int num; public: test( ); int getint( ) {return num;} ~test( );}; test::test( ) { num=0;} test::~test( ) { cout<<"Destructor is active"<<endl;} vo

  • 查看答案
  • 写出程序的输出结果class Class1 { private string s