Giventhefollowingcode:1)classParent{2)privateStringname;3)publicParent(){}4)}5)publicclassChildextendsParent{6)privateStringdepartment;7)publicChild(){}8)publicStringgetValue(){returnname;}9)publicstaticvoidmain(Stringarg[]){10)Parentp=newParent();11)}12)}Whichlinewillcauseerror?()
A.line3
B.line6
C.line7
D.line8
E.line10
第1题:
classParent{
Stringone,two;
publicParent(Stringa,Stringb){
one=a;
two=b;}
publicvoidprint(){System.out.println(one);}}
publicclassChildextendsParent{
publicChild(Stringa,Stringb){
super(a,b);
}
publicvoidprint(){
System.out.println(one+"to"+two);
}
publicstaticvoidmain(Stringarg[]){
Parentp=newParent("south","north");
Parentt=newChild("east","west");
p.print();
t.print();
}
}
Whichofthefollowingiscorrect?()
第2题:
有如下程序:
include <iostream>
using namespace std;
class PARENT
{
public:
PARENT() { cout <<"PARENT"; }
};
class SON : public PARENT
{
public:
SON() {cout << "SON"; }
};
int main()
{
SON son;
PARENT *p;
p = &son;
return 0;
}
执行上面程序的输出是______。
第3题:
一个 java源文件可以定义几个public class?
A.0
B.1
C.2
D.3
第4题:
Giventhefollowingcode:1)publicvoidmodify(){2)inti,j,k;3)i=100;4)while(i>0){5)j=i*2;6)System.out.println("Thevalueofjis"+j);7)k=k+1;8)i--;9)}10)}Whichlinemightcauseanerrorduringcompilation?()
A.line4
B.line6
C.line7
D.line8
第5题:
一个 java源文件可以定义几个public class?()。
A.0
B.1
C.2
D.3