单选题编译如下的Java程序片段: Class test{ Int count=9; Public void a(){ Int count=10; System.out,println(“count 1=” + count); } Public void count(){ System.out.println(“count 2 =”+ count); } Public static void main(String args[] ){ Test t=new Test(); t.a(); t.count(); } } 结果是()A不能通过编译B输出:count 1 =10 count 2=9C输出:count 1=9 count 2=9
单选题
编译如下的Java程序片段: Class test{ Int count=9; Public void a(){ Int count=10; System.out,println(“count 1=” + count); } Public void count(){ System.out.println(“count 2 =”+ count); } Public static void main(String args[] ){ Test t=new Test(); t.a(); t.count(); } } 结果是()
A
不能通过编译
B
输出:count 1 =10 count 2=9
C
输出:count 1=9 count 2=9
参考解析
解析:
暂无解析
相关考题:
有如下类定义:class Test{public:Test(){ a = 0; c = 0;} // ①int f(int a)const{this-a = a;} // ②static int g(){return a;} // ③void h(intB . {Test::b = b;}; // ④private:int a;static int b;const int c;};int Test::b = 0;在标注号码的行中,能被正确编译的是A . ①B . ②C . ③D . ④
如下程序的输出结果是______。 include using namespace std; class pumpkin{ publ 如下程序的输出结果是______。include<iostream>using namespace std;class pumpkin{public:pumpkin( ){++count;}~pumpkin( ){--eount;}static void total_count( ){cout<<count<<"pumpkin(s)"<<endl;}private:static int count;};int pumpkin::count=0;int main( ){pumpkin pl[10];pumpkin::total_count( );return 0;}
下面程序的运行结果是【】。 inChlde using namespace std; class count { static int n; 下面程序的运行结果是【 】。inChlde<iOStream>using namespace std;class count{static int n;public:count(){n++;}static int test(){for(int i=0:i<4;i++)n++;return n;}};int count::n=0;int main(){cout<<COUnt::test()<<" ";count c1, c2;cout<<count::test()<<end1;return 0;}
使用VC6打开考生文件夹下的工程ms9_1,此工程包含一个源程序文件test9_1.cpp,但该程序运行有问题,请改正程序中的错误,使程序的输出结果如下:4,520源程序文件test9_1.cpp清单如下:include<iostream.h>class A{protected:int n,m;public:void set(int a,int b){m=a; n=b;)void show(){cout<<m<<","<<n<<endl;)/**********found*********/}class B:public A{int s;public:void set(){s=m*n;)void shows(){cout<<s<<endl;)};void main(){B b;/**********found**+******/b.set();b.show();b.set();/*********found**********/b.show();}
下列程序片段中,能通过编译的是A.public abstract class Animal{ public void speak();}B.public abstract class Animal{ public void speak(){}}C.public class Animal{ public abstract void speak();}D.public abstract class Animal{ public abstract void speak(){}}
如下程序的输出结果是( )。 public class Test { void printValue(int m) { do { System.out.println("The value is"+m); } while( --m>10) } public static void main(String args[]) { int i=10; Test t=new Test(); t.printValue(i); } }A.The value is 8B.The value is 9C.The value is 10D.The value is 11
有如下程序:includeusing namespace std;Class TestClass{private:int x,y;public:Te 有如下程序: #include<iostream> using namespace std; Class TestClass { private: int x,y; public: TestClass(int i,int j) { x=i; y=j; } void print() { cout<<“print1”<<endl; } void print()const { cout<<”prinA.printlB.print2C.printl print2D.程序编译时出错。
已知如下类说明: public class Test { private float f = 1.0f; int m = 12; static int n=1; public static void main(String arg[]) { Test t = new Test(); // 程序代码… } } 如下哪个使用是正确的?() A.t.fB.this.nC.Test.mD.Test.n
在如下源代码文件Test.java中, 哪个是正确的类定义?() A.public class test { public int x = 0; public test(int x) { this.x = x; } }B.public class Test{ public int x=0; public Test(int x) { this.x = x; } }C.public class Test extends T1, T2 { public int x = 0; public Test (int x) { this.x = x; } }D.public class
下列程序的执行结果是 ( ) public class Test { public int aMethod() { satic int i=0; i++; System.out.println(i); } public static void.main(String args[]) { Test test=new Test(); test.aMethod(); }A.编译错误B.0C.1D.运行成功,但不输出
如下两个源程序文件,分别编译后,运行Example.class文件,运行结果为______。AB.java文件代码如下;package test;public class AB{int a=60;public void show(){System.out.println(”a=”+a);}Example.java文件代码如下:import test.AB;class Example{public static void main(String args[]){AB bj=new AB();obj.show();}}
下列哪个选项的java源文件代码片段是不正确的?A.package testpackage; public class Test{ }B.import java. io. *; package testpaekage; public class Test { }C.import java.io.*; class Person { } public class Test { }D.import java.io.*; import java. awt.*; public class Test{ }
有如下程序: include using namespace std; class pumpkin{ public:pumpkin(){++count 有如下程序:include<iostream>using namespace std;class pumpkin{public:pumpkin(){++count;}~pumpkin(){--count;}static void total_count(){cout<<count<<"pumpkin(s)"<<end1;}private:static int count;};int pumpkin::count=0;int main(){pumpkin p1[10];pumpkin::total_count();return 0;}这个程序的输出结果是______。
下面程序执行后,baz的值应是______。 public class Test9 { public static void main(String[] args) { int index = 1; int fox[] = new int [3]; iht bar = fox [index]; int baz = bar + index; System.out.println(baz); } }A.0B.1C.2D.编译错误
下列程序片段中,能通过编译的是( )。A.public abstract class Animal{public void speak( );}B.public abstract class Animal{public void speak( ){};}C.public class Animal{pubilc abstract void speak( );}D.public abstract class Animal{pubile abstract void speak( ){};}
有如下类定义: class Test { public: Test(){a=0;c=0} //① int f(int a)const{this->a=a;} //② static int g(){return a;} //③ void h(int b){Test::b;}; //④ private: int a; static int b; const int C; }; int Test::b=0; 在标注号码的行中,能被正确编译的是( )。A.①B.②C.③D.④
有以下程序:include using namespace std;class count{ static int n;public: count 有以下程序: #include <iostream> using namespace std; class count { static int n; public: count ( ) { n++; } static int test() { for (int i = 0; i < 4; i++ ) n++; return n; } }; int count :: n = 0; int main() { cout<<count :: test()<<" "; count c1, c2; cout<<count :: test()<<end1; return 0; } 执行后的输出结果是( )。A.4 10B.1 2C.22D.24
下列程序test类中的变量e的最后结果为( )。 public class test { public static void main (String args[]) { int a=10; int b; int c; if(a>50) { b=9; } c=b+a; } }A.10B.0C.19D.编译出错
有如下程序:includeusing namespace std;class MyClass{public:MyClass(){++count;}~ 有如下程序: #include<iostream> using namespace std; class MyClass{ public: MyClass(){++count;} ~MyClass(){--count;} static int getCount(){return count;} private: static int count; }; int MyClass::count=0; int main(){ MyClA.121B.232C.221D.122
下列程序片段中,能通过编译的是( )。 A.public abstract class Animal{ public void speak;}S 下列程序片段中,能通过编译的是( )。A.public abstract class Animal{ public void speak;}B.public abstract class Animal{ public void speak{);}C.public class Animal{ pubilc abstract void speak;}D.public abstract class Animal{ pubile abstract void speak{};}
下列程序的输出结果是______。 include using namespace std; class Test( public: Te 下列程序的输出结果是______。 #include<iostream> using namespace std; class Test( public: Test() {cnt++;} ~Test() {cnt--;} static int Count(){return cnt;} private: static int cnt; }; int Test::cnt=0; int main() { cout<<Test::Count()<<""; Test t1,t2; Test*pT3=new Test; Test*pT4=new Test; cout<<Test::Count()<<""; delete pT4; delete pT3; cout<<Test::Count()<<end1; return 0; }A.024B.042C.420D.240
以下程序调试结果为:public class Test {int m=5;public void some(int x) {m=x;}public static void main(String args []) {new Demo().some(7);}}class Demo extends Test {int m=8;public void some(int x) {super.some(x);System.out.println(m);}}A.5B.8C.7D.无任何输出E.编译错误
如下程序编译时发生错误,错误的原因是show函数实现语句错误,则正确的语句应该为______。include<iostream.h>class test{private:int hum;public:test(int);void show( );};test::test(int n){num=n;}test::show( ){cout<<num<<endl;}void main( ){test T(10):T.show( );}
给定java代码如下所示,在A处新增下列()方法,是对cal方法的重载。public class Test { public void cal(int x, int y, int z) { } //A } A、public int cal(int x,int y,float z){return 0;}B、public int cal(int x,int y,int z){return 0;}C、public void cal(int x,int z){}D、public viod cal(int z,int y,int x){}
给定如下Java程序片断: class A{ public A (){ System.out.println("A"); } } class B extends A{ public B(){ System.out.println("B"); } public static void main(String[] args){ B b=new B(); } } 上述程序将()。 A、不能通过编译B、通过编译,输出为:A BC、通过编译,输出为:BD、通过编译,输出为:A
编译如下Java程序片断: class test{ int count = 9; public void a(){ int count=10; System.out.println("count 1 =" + count); } public void count(){ System.out.println("count 2 =" + count); } public static void main(String args[]){ test t=new test(); t.a(); t.count(); } } 结果将()。 A、不能通过编译B、输出: count 1 = 10 count 2 = 9C、输出:count 1 = 9 count 2 = 9
单选题编译如下Java程序片断: class test{ int count = 9; public void a(){ int count=10; System.out.println("count 1 =" + count); } public void count(){ System.out.println("count 2 =" + count); } public static void main(String args[]){ test t=new test(); t.a(); t.count(); } } 结果将()。A不能通过编译B输出: count 1 = 10 count 2 = 9C输出:count 1 = 9 count 2 = 9
单选题编译如下的Java程序片段: Class test{ Int count=9; Public void a(){ Int count=10; System.out,println(“count 1=” + count); } Public void count(){ System.out.println(“count 2 =”+ count); } Public static void main(String args[] ){ Test t=new Test(); t.a(); t.count(); } } 结果是()A不能通过编译B输出:count 1 =10 count 2=9C输出:count 1=9 count 2=9