int addValue( int a, int b ){// do something...}
public void addValue (){// do something...}
public int addValue( int a ){// do something...}
public int addValue( int a, int b )throws MyException {//do something...}
第1题:
A.private void fun( int n ){ //...}
B.void fun ( int n ){ //... }
C.protected void fun ( int n ) { //... }
D.public void fun ( int n ) { //... }
第2题:
下列程序中的this指针的作用是【 】。
include <iostream. h>
class Sample
{
int n;
static int st;
public,
Sample() {}
Sample(int m) {n=m; st=m+10;}
void Change(int k) {st=st+k;}
void AddValue(int m)
{
Sample s,
s. n=n+m;
*this=s;
}
void disp( ) {cout<<"n="<<n<<";st="<<st<<end1;}
};
int Sample: :st=0
void main()
{
Sample s1(10),s2(10)
s1.disp()
s1.AddValue(5),
s2.Change(100);
s1.disp();
s2.disp()
}
第3题:
有以下程序: #include <iostream> using namespace std; class sample { private: iht n; public: sample(){} sample(int m) { n=m; } void addvalue(int m) { sample s; s.n=n+m; *this=s; } void disp() { cout<<"n="<<n<<end1; } }; int main() { sample s(10); s.addvalue(5); s.disp(); return 0; } 程序运行后的输出结果是
A.n=10
B.n=5
C.n=15
D.n=20
第4题:
若有以下程序: #include 〈iostream〉 using namespace std; class sample { private: int n; public: sample(){} sample(int m) { n=m; } void addvalue(int m) { sample s; s.n=n+m; *this=s; } void disp() { cout〈〈"n="〈〈n〈〈end1; } }; int main() { sample s(10); s.addvalue(5); s.disp(); return 0; } 程序运行后的输出结果是( )。
A.n=10
B.n=5
C.n=15
D.n=20
第5题:
class A { protected int method1(int a, int b) { return 0; } } Which two are valid in a class that extends class A?()
第6题:
public class Parent{ public void change(int x){} } public class Child extends Parent{ //覆盖父类change方法 } 下列哪个声明是正确的覆盖了父类的change方法?()
第7题:
public class Parent { public int addValue( int a, int b) { int s; s = a+b; return s; } } class Child extends Parent { } Which methods can be added into class Child?()
第8题:
public class Parent { int change() {…} } class Child extends Parent { } Which methods can be added into class Child?()
第9题:
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?()
第10题:
i = m;
i = b;
i = p.a;
i = p.change(30);
i = t.b.
第11题:
public int change(){}
int chang(int i){}
private int change(){}
abstract int chang(){}
第12题:
public void foo() { }
public int foo() { return 3; }
public Two foo() { return this; }
public One foo() { return this; }
public Object foo() { return this; }
第13题:
若有以下程序: #include<iostream> using namespace std; class sample { private: int n; public: sample(){} sample(int m) { n=m; } void addvalue(int m) { sample s; s.n=n+m; *this=s; } void disp() { cout<<"n"=<<n<<end1; } }; int main() { sample s(10); s.addvalue(5); s.disp(); return 0; } 程序运行后的输出结果是
A.n=10
B.n=5
C.n=15
D.n=20
第14题:
有以下程序: #include <iostream> using namespace std; class A { private: int x,y; public: void set (int i,int j) { x=i; y=j; } int get_y() { return y; } }; class box { private: int length,width; A label; public: void set(int 1,int w, int s,int p) { length=1; width=w; label.set(s,p); } int get_area() { return length*width; } }; int main() { box small; small.set(2,4,1,35); cout<<small.get_area()<<end1; return 0; } 运行后的输出结果是( )。
A.8
B.4
C.35
D.70
第15题:
分析以下程序的执行结果【 】。
include <iostream. h>
class S{
int A[10];
public:
int &operator () (int);
};
int &S: :operator() (int x) {
return A[x];
}
void main() {
S a;
int i,j;
for (i=0; i<10; i++)
a(i)=i*2;
for (i=0; i<10; i++)
cout<<a(i)<<" ";
cout<<end1; }
第16题:
有如下程序: #include<iostream> using namespace std; int s=0; class sample { static int n; public: sample(int i) { n=i; } static void add() { s+=n; } }; int sample::s=0; int main() { sample a(2),b(5); sample::add(); cout<<s<<endl; return 0; } 程序运行后的输出结果是
A.2
B.5
C.7
D.3
第17题:
Which are syntactically valid statement at// point x?() class Person { private int a; public int change(int m){ return m; } } public class Teacher extends Person { public int b; public static void main(String arg[]){ Person p = new Person(); Teacher t = new Teacher(); int i; // point x } }
第18题:
public class Score implements Comparable
第19题:
public class MethodOver { public void setVar (int a, int b, float c) { } } Which two overload the setVar method?()
第20题:
现有 public class Parentt public void change (int x){) ) public class Child extends Parent{ //覆盖父类change方法 } 下列哪个声明是正确的覆盖了父类的change方法?()
第21题:
Private void setVar (int a, float c, int b) { }
Protected void setVar (int a, int b, float c) { }
Public int setVar (int a, float c, int b) (return a;)
Public int setVar (int a, int b, float c) (return a;)
Protected float setVar (int a, int b, float c) (return c;)
第22题:
int addValue( int a, int b ){// do something...}
public void addValue (){// do something...}
public int addValue( int a ){// do something...}
public int addValue( int a, int b )throws MyException {//do something...}
第23题:
protected void change (int x){}
public void change(int x, int y){}
public void change (int x){}
public void change (String s){}
第24题:
public class Circle implements Shape { private int radius; }
public abstract class Circle extends Shape { private int radius; }
public class Circle extends Shape { private int radius; public void draw(); }
public abstract class Circle implements Shape { private int radius; public void draw(); }
public class Circle extends Shape { private int radius;public void draw() {/* code here */} }
public abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }