单选题现有: class Wrench2 { int size; public static void main(String [] args) { Wrench2 w=new Wrench2(); w.size=II; Wrench2 w2=go(w, w.size); System. out .print (w2. size); } static Wrench2 go(Wrench2 wr. int s) { S=12; return wr; } } 结果为()A 11B 12C编译失败D运行时异常被抛出
单选题
现有: class Wrench2 { int size; public static void main(String [] args) { Wrench2 w=new Wrench2(); w.size=II; Wrench2 w2=go(w, w.size); System. out .print (w2. size); } static Wrench2 go(Wrench2 wr. int s) { S=12; return wr; } } 结果为()
A
11
B
12
C
编译失败
D
运行时异常被抛出
参考解析
解析:
暂无解析
相关考题:
有如下程序:includeusing namespace std;class A{public:static int a;void init(){a 有如下程序: #include<iostream> using namespace std; class A{ public: static int a; void init(){a=1;} A(int a=2){init(); a++;} }; int A::a=0; A obj; int main() { cout<<obj.a; return 0; 运行时输出的结果是( )。A.0B.1C.2D.3
下面程序的输出结果是什么? class C1{ static int j=0; public void method(int a){ j++; } } class Test extends C1{ public int method(){ return j++; } public void result(){ method(j); System.out.println(j+method()); } public static void main(String args[]){ new TeA.0B.1C.2D.3
下列程序的运行结果是【 】。 include class SomeClass { public: SomeClass(int va 下列程序的运行结果是【 】。include <iostream. h>class SomeClass{public:SomeClass(int value) { some_value=value;};void show_data(void) { cout<<data<<"<<~some_value<<endl; };static void set_data(int value) {data=value; }private:static int data;int some_value};int SomeClass::datavoid main(void){SomeClass my_class(1001),your_class(2002);your_class. set_data(4004);my_elass. show_data()}
下面程序编译时发现ma[3]=9错误,其原因是______。 include class FunArray { int*pa; 下面程序编译时发现ma[3]=9错误,其原因是______。include<iostream.h>class FunArray{int*pa; //指向一个数组空问int size; //数组元素个数public:FunArray(int a[],int thesize):pa(a),size(thesize){}int Size( ){return size;}}};void main( ){int s[]={3,7,2,1,5,4};FunArray ma(s,sizeof(s)/sizeof(int));ma[3]=9;cout<<ma[3]<<endl;}
下面程序段的输出结果是 class Base { int i; Base() { add(1); } void add(int v) { i+=v; } void print() { System.out.println(i); } } class Extension extends Base { Extension() { add(2); } void add(int v) { i+=v*2; } } public class Test { public static void main(String args[]) { bogo(new Extension()); } static void bogo(Baseb){ b.add(8); b.print(); } }A.9B.18C.20D.22
请在每条横线处填写一个语句,使程序的功能完整,且输出结果为91 1。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。源程序文件代码清单如下:public class Outer{public static void main (String args[]{Outer i = new Outer();i,taskInner();}public class Inner{private int size;public void doSomething(int size){_____________//访问局部变量this. size++; //访问内部类的成员变量_____________//访问外部类的成员变量System.out.println(size+" "+this.size+" "+Outer.this.size);}}public void taskInner(){___________k.doSomething(8);}private static int size;}
下列程序段中,正确的是______。 ①class MvClass { int var = 100; static int getVar() { return var; } } ②public class MyClass { final int date; void MyClass (int d) { date = d; } } ③public class MyMain { public static void main(String args[]) { System.out.println(Myclass1.date); } } class MyClass1 { int data = 10; } ④class IamAbstract { final int f; double d; abstrct void method(); }A.②④B.①③C.②D.以上都不对
interface A{int x = 0;}class B{int x =1;}class C extends B implements A {public void pX(){System.out.println(x);}public static void main(String[] args) {new C().pX();}}
下面的例子中using System;class A{public static int X;static A(){X=B.Y+1;}}class B{public static int Y=A.X+1;static B(){}static void Main(){Console.WriteLine("X={0},Y={1}",A.X,B.Y);}}产生的输出结果是什么?
1) class Person { 2) public void printValue(int i, int j) {/*…*/ } 3) public void printValue(int i){/*...*/ } 4) } 5) public class Teacher extends Person { 6) public void printValue() {/*...*/ } 7) public void printValue(int i) {/*...*/} 8) public static void main(String args[]){ 9) Person t = new Teacher(); 10) t.printValue(10); 11) } 12) } Which method will the statement on line 10 call?() A、 on line 2B、 on line 3C、 on line 6D、 on line 7
现有: class TestApp{ public static void main (String[] args){ for (int i=0; iA、0123B、012456789C、0123456789D、012
public class Test { public static void leftshift(int i, int j) { i=j; } public static void main(String args[]) { int i = 4, j = 2; leftshift(i, j); System.out.printIn(i); } } What is the result?() A、 2B、 4C、 8D、 16E、 The code will not compile.
public class Yikes { public static void go(Long n) {System.out.println(”Long “);} public static void go(Short n) {System.out.println(”Short “);} public static void go(int n) {System.out.println(”int “);} public static void main(String [] args) { short y= 6; long z= 7; go(y); go(z); } } What is the result?() A、 int LongB、 Short LongC、 Compilation fails.D、 An exception is thrown at runtime.
现有: class Top { static int x=l; public Top (inty) { x*=3; } } class Middle extends Top { public Middle() {x+=1; ) public static void main (String [] args) { Middle m = new Middle(); System. out .println (x); } } 结果为:() A、1B、2C、3D、编译失败
现有: class Wrench2 { int size; public static void main(String [] args) { Wrench2 w=new Wrench2(); w.size=II; Wrench2 w2=go(w, w.size); System. out .print (w2. size); } static Wrench2 go(Wrench2 wr. int s) { S=12; return wr; } } 结果为() A、 11B、 12C、编译失败D、运行时异常被抛出
现有 public class Parentt public void change (int x){) ) public class Child extends Parent{ //覆盖父类change方法 } 下列哪个声明是正确的覆盖了父类的change方法?() A、 protected void change (int x){}B、 public void change(int x, int y){}C、 public void change (int x){}D、 public void change (String s){}
public abstract class Shape { private int x; private int y; public abstract void draw(); public void setAnchor(int x, int y) { this.x = x; this.y = y; } } Which two classes use the Shape class correctly?()A、 public class Circle implements Shape { private int radius; }B、 public abstract class Circle extends Shape { private int radius; }C、 public class Circle extends Shape { private int radius; public void draw(); }D、 public abstract class Circle implements Shape { private int radius; public void draw(); }E、 public class Circle extends Shape { private int radius;public void draw() {/* code here */} }F、 public abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }
单选题现有: class Top { static int X=l; public Top() { x*=3; } } class Middle extends Top { public Middle() {x+=l; } public static void main(String [] args) { Middle m=new Middle(); System.out.println (x); } } 结果是什么?()A 2B 3C 4D编译失败
单选题现有: class Passer f static final int X=5; public static void main (String [] args) { new Passer().go (x); System. out .print (x); } void go (int x) { System. out .print(x++); } 结果是什么?()A55B56C65D66
单选题现有 public class Parentt public void change (int x){) ) public class Child extends Parent{ //覆盖父类change方法 } 下列哪个声明是正确的覆盖了父类的change方法?()A protected void change (int x){}B public void change(int x, int y){}C public void change (int x){}D public void change (String s){}
单选题public class Yikes { public static void go(Long n) {System.out.println(”Long “);} public static void go(Short n) {System.out.println(”Short “);} public static void go(int n) {System.out.println(”int “);} public static void main(String [] args) { short y= 6; long z= 7; go(y); go(z); } } What is the result?()A int LongB Short LongC Compilation fails.D An exception is thrown at runtime.
单选题现有: class Top { static int x=l; public Top (inty) { x*=3; } } class Middle extends Top { public Middle() {x+=1; ) public static void main (String [] args) { Middle m = new Middle(); System. out .println (x); } } 结果为:()A1B2C3D编译失败
多选题现有: public class TestDemo{ private int X-2; static int y=3; public void method(){ final int i=100; int j =10; class Cinner { public void mymethod(){ //Here } } } } 在Here处可以访问的变量是哪些?()AXByCjDi
单选题现有: class Banana2 f static int X=2; public static void main (String [] args) { int X=2; Banana2 b=new Banana2(); b.go(x); } static {x+=x; } void go (int x) { ++x; System. out.println (x); } 结果为:()A7B5C3D2
单选题class Wrench2 { int size; public static void main(String [] args) { Wrench2 w = new Wrench2(); w.size = 9; Wrench2 w2 = go(w, w.size); System.out.print(w2.size); } static Wrench2 go(Wrench2 wr, int s) { s = 7; return wr; } } 结果为:()A7B9C编译失败D输出结果不可预料
多选题public class TestDemo{ private int x = 2; static int y = 3; public void method(){ final int i=100; int j = 10; class Cinner{ public void mymethod(){ //Here } } } } 在Here处可以访问的变量是哪些?()AxByCiDj
单选题现有: class TestApp{ public static void main (String[] args){ for (int i=0; iA0123B012456789C0123456789D012