更多“class A { int x; int add() { return x+1; } } System.out.println(a); 则程序的运行结果是()。”相关的问题
第1题
指出下列程序中的错误,并简洁说明错误原因 class AC { public: AC(int a) { x = a; } private: int x; }; class CD:public AC { public: CD(){ } };
点击查看答案
第2题
请阅读下面的程序 Public class Test { public static void main(String[] args) { int a = 0; int b = 0; for (int i = 1; i <= 5; i++) { a="i" % 2; while (a-->= 0) { b++; } } System.out.println("a=" + a + ",b="+ b); } } 下列选项中,哪一个是正确的运行结果( )
A、a=8,b=-2
B、a=-2,b=8
C、a=3,b=0
D、a=0,b=3
点击查看答案
第3题
package Ch6; public class TestException2 { public static int method1(int x) { try { if (x < 0) throw new Exception("x<0"); return x++; } catch (exception e) { system.out.println("wrong"); -100; finally system.out.println("finally"); public static void main(string args[]) system.out.println(method1(1));>
点击查看答案
第4题
如果有下面的程序: class A { int x ; int y ; public: A(int a,int b) { x = a ; y = b ; } A(A &a) { x = a.x *1000 ; y = a.y *1000 ; } void display() { cout << x << "," << y ; } } ; A a1(2,5); A a2(a1) ; a2.display() ; 则该程序的显示输出是()。
A、2000,5000
B、5000,2000
C、2,5
D、5,2
点击查看答案
第5题
假设已编写好了类Class1: package Testpackage; public class Class1{ … … } 它存在于Class1.java 文件中。 现在main 方法所在的源程序MainPro.java 如 下: import Testpackage; … … 设Windows操作系统中的CLASSPATH 环境变量已被设成".",而main方法所在的源程序MainPro.java 存在目录c:\Testdir 中,且当前工作目录为c:\Testdir, 那么Class1.class文件应存放在那个目录中呢?请从盘符开始书写目录名称。
点击查看答案
第6题
以下程序的运行结果为? public class Test { static int count; public static void main(String args[]) { int sum=0; for (int count=0;count<4;count++) sum+="count;" system.out.println(count); }> A、4
点击查看答案
第7题
以下内容在同一个源程序中: interface A { int add(); } class B implements A { int x,y; B(int x,int y) { this.x=x; this.y=y; } int add() { return x+y; } } public class C { public static void main(String[] args) { B b=new B(10,20); int result=b.add(); System.out.println(b.x); System.out.println(b.y); System.out.println(result); } } 对于这个源程序,以下选项正确的是( )。
A、程序输出b.x的值为0
B、程序输出b.y的值为0
C、程序输出的result的值为30
D、上述源程序编译不通过
点击查看答案
第8题
StringBuffer str=new StringBuffer("abc"); 如果让str指向的字符串变为“abcdef”,以下选项中,能够完成任务的是( )。
A、str.insert(2,"def");
B、str.add("def");
C、str.append("def");
D、str指向的内容不能改变
点击查看答案
第9题
BigInteger a=new BigInteger("123456789123456789");则a.toString()的值是( )。
点击查看答案