insert a call to this() in the Car constructor
insert a call to this() in the MeGo constructor
insert a call to super() in the MeGo constructor
insert a call to super(vin) in the MeGo constructor
change the wheelCount variable in Car to protected
change line 3 in the MeGo class to super.wheelCount = 3;
第1题:
有以下程序: #include<iostream> using namespace std; class A {private: int a; public: A(int i) {a=i;} void disp() {cout<<a<<“,”;}}; class B {private: int b; public: B(int j) {b=j;} void disp() {cout<<b<<“,”;
A.10,10,10
B.10,12,14
C.8,10,12
D.8,12,10
第2题:
给出下列代码,如何使成员变量m被方法fun( )直接访问?Class Test{private int m;public static void fun( ){} }
A.将private int m改为protected int m
B.将private int m改为public int m
C.将private int m改为static int m
D.将private int m改为int m
第3题:
请在mian函数中填空使下面程序的输出结果为1 1。
include<iostream.h>
class A
{ private:
int a;
int b;
public:
A( ):a(0) ,b(1) { }
void show( ) { cout < < a < < " " < < b;} };
class B
{ private:
int a;
int c;
public:
B( ):a(1),
第4题:
有以下程序: #include <iostream> using namespace std; class A { private: int a; public: A (int i) { a=i; } void disp() { cout<<a<<","; } }; class B { private: int b; public: B(int j) { b=j; } void disp() { cout<<b<<","; } }; class C : public B,public A { private: int c; public: C(int k) :A(k-2),B(k+2) { c=k; } void disp () { A::disp (); B::disp (); cout<<c<<endl; } }; int main () { C obi (10); obj.disp (); return 0; } 程序执行后的输出结果是
A.10,10,10
B.10,12,14
C.8,10,12
D.8,12,10
第5题:
给出下列代码,如何使成员变量m被方法fun( )直接访问? class Test{ private int m; public static void fun( ){ … } }
A.将private int m改为protected int m
B.将private int m改为public int m
C.将private int m改为static i
D.将private int m改为int m
第6题:
若有如下程序: #include<iostream> using namespace std; Class TestClass1 { private: int a; public: TestClassl(int i) { a=i; } void disp() { cout<<a<<“,”; } }; Class TestClass2 { private: int b; public
A.10,10,10
B.10,12,14
C.8,10,12
D.8,12,10
第7题:
若有以下程序 #include <iostream> using namespace std; class A { private: int a; public: A(int i) { a=i; } void disp() { cout<<a<<","; } }; class B { private: int b; public: B(int j) { b=j; } void disp() { cout<<b<<","; } }; class C: public B,public A { private: int c; public: C(int k):A(k-2),B(k+2) { c=k; } void disp() { A::disp(); B::disp(); cout<<c<<end1; } }; int main() { C obj(10); obj.disp(); return 0; } 程序执行后的输出结果是
A.10,10,10
B.10,12,14
C.8,10,12
D.8,12,10
第8题:
能将程序补充完整的选项是( )。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; ______ }} B.
A.i=m
B.i=b
C. i=p.a
D.i=p. change(50)
第9题:
下面这个程序的结果是
#include<iostream.h>
class A
{
private:
int a;
public:
void seta( ) ;int geta( ) ;};
void A: :seta( )
{ a=1;}
int A: :geta( )
{ retum a;}
class B
{ private:
int a;
public:
void seta( ) ;int geta( ) ;};
void B: :seta( )
{a=2;}
int B: :geta( )
{return a;}
class C: public A,public B
{ private:
int b;
public:
void display( ) ;};
void C: :display( )
{ int b=geta( ) ;
cout < < b;}
void main( )
{ C c;
c. seta( ) ;
c. display( ) ;}
A.1
B.2
C.随机输出1或2
D.程序有错
第10题:
public class Something {
void doSomething () {
private String s = "";
int l = s.length();
}
}
有错吗?
错。局部变量前不能放置任何访问修饰符 (private,public,和protected)。final 可以
用来修饰局部变量
(final 如同abstract 和strictfp,都是非访问修饰符,strictfp 只能修饰class 和method 而非
variable)。