华南理工大学java模拟题 5Word格式.docx
- 文档编号:18645051
- 上传时间:2022-12-30
- 格式:DOCX
- 页数:20
- 大小:18.21KB
华南理工大学java模拟题 5Word格式.docx
《华南理工大学java模拟题 5Word格式.docx》由会员分享,可在线阅读,更多相关《华南理工大学java模拟题 5Word格式.docx(20页珍藏版)》请在冰豆网上搜索。
System.out.println(str2==str3);
System.out.println(str2==str4);
System.out.println(str5==str1);
False,false,false,true
3、阅读以下程序,写出输出结果。
publicclassGroupTwo{
privateintcount;
publicclassStudent{
Stringname;
publicStudent(Stringn1){
name=n1;
count++;
}
publicvoidOutput(){
System.out.println(this.name);
publicvoidoutput(){
Students1=newStudent("
Johnson"
s1.Output();
System.out.println("
count="
+this.count);
GroupTwog2=newGroupTwo();
g2.output();
Johnson
Count=1
4、阅读以下程序,写出输出结果。
classsuperClass{
inty;
superClass(){
y=30;
insuperClass:
y="
+y);
voiddoPrint(){
InsuperClass.doPrint()"
classsubClassextendssuperClass{
subClass(){
super();
y=50;
insubClass:
super.doPrint();
insubClass.doPrint()"
super.y="
+super.y+"
sub.y="
publicclassinviteSuper{
subClasssubSC=newsubClass();
subSC.doPrint();
y=30
y=50
InsuperClass.doPrint()
insubClass.doPrint()
super.y=30sub.y=50
5、阅读以下程序,写出输出结果。
publicclassGroupThree{
privatestaticintcount;
privateStringname;
publicclassStudent{
privateintcount;
privateStringname;
publicvoidOutput(intcount){
this.count++;
GroupThree.count++;
GroupThree.this.count++;
System.out.println(count+"
"
+this.count+"
+GroupThree.count+"
+GroupThree.this.count++);
publicStudentaStu()
{
returnnewStudent();
GroupThreeg3=newGroupThree();
g3.count=10;
GroupThree.Students1=g3.aStu();
GroupThree.Students1.Output(5);
611212
6、阅读以下程序,写出输出结果。
classMammal{
privateintn=40;
voidcrySpeak(Strings){
publicclassMonkeyextendsMammal{
voidcomputer(intaa,intbb){
intcc=aa*bb;
System.out.println(cc);
**"
+s+"
Mammalmammal=newMonkey();
mammal.crySpeak("
Ilovethisgame"
Monkeymonkey=(Monkey)mammal;
puter(10,10);
**Ilovethisgame**
100
7、阅读以下程序,写出输出结果。
publicclassFlower{
intpetalCount=0;
Strings="
initialvalue"
Flower(intpetals){
petalCount=petals;
print("
Constructorw/intargonly,petalCount="
+petalCount);
Flower(Stringss){
Constructorw/Stringargonly,s="
+ss);
s=ss;
Flower(Strings,intpetals){
this(petals);
this.s=s;
//Anotheruseof"
this"
String&
intargs"
Flower(){
this("
hi"
47);
defaultconstructor(noargs)"
voidprintPetalCount(){
petalCount="
+petalCount+"
s="
+s);
voidprint(Strings){
Flowerx=newFlower();
x.printPetalCount();
Constructorw/intargonly,petalCount=47
intargs
defaultconstructor(noargs)
petalCount=47s=hi
8、阅读以下程序,写出输出结果。
classCup{
Cup(intmarker){
System.out.println("
Cup("
+marker+"
)"
voidf(intmarker){
f("
classCups{
staticCupcup1;
staticCupcup2;
static{
cup1=newCup
(1);
cup2=newCup
(2);
Cups(){
Cups()"
publicclassExplicitStatic{
Insidemain()"
Cups.cup1.f(99);
Insidemain()
Cup
(1)
Cup
(2)
f(99)
9、阅读以下程序,写出输出结果。
classTree{
intheight;
Tree(){
Plantingaseedling"
height=0;
Tree(intinitialHeight){
height=initialHeight;
CreatingnewTreethatis"
+
height+"
feettall"
}
voidinfo(){
System.out.println("
Treeis"
+height+"
voidinfo(Strings){
System.out.println(s+"
:
Treeis"
publicclassOverloading{
for(inti=0;
i<
5;
i++){
Treet=newTree(i);
t.info();
t.info("
overloadedmethod"
//Overloadedconstructor:
newTree();
CreatingnewTreethatis0feettall
Treeis0feettall
overloadedmethod:
Treeis0feettall
CreatingnewTreethatis1feettall
Treeis1feettall
Treeis1feettall
CreatingnewTreethatis2feettall
Treeis2feettall
Treeis2feettall
CreatingnewTreethatis3feettall
Treeis3feettall
Treeis3feettall
CreatingnewTreethatis4feettall
Treeis4feettall
Treeis4feettall
Plantingaseedling
10、阅读以下程序,写出输出结果。
classA{
doublef(doublex,doubley){
returnx*y;
classBextendsA{
returnx+y;
publicclassTest{
Bobj=newB();
Theprogramoutputis"
+obj.f(6,7));
Theprogramoutputis13.0
11、阅读以下程序,写出输出结果。
classLargeCup{
LargeCup(intmarker){
LargeCup("
voidf1(intmarker){
f1("
classShelf{
staticLargeCupcup1=newLargeCup
(1);
Shelf(){
Shelf()"
cup2.f1
(1);
voidf2(intmarker){
f2("
staticLargeCupcup2=newLargeCup
(2);
classCupshelf{
staticLargeCupcup3=newLargeCup(3);
staticLargeCupcup4=newLargeCup(4);
Cupshelf(){
Cupshelf()"
cup4.f1
(2);
voidf3(intmarker){
f3("
staticLargeCupcup5=newLargeCup(5);
publicclassInitialization{
staticShelfshelf=newShelf();
staticCupshelfcupshelf=newCupshelf();
System.out.println("
CreatingnewCupshelf1()inmain"
newCupshelf();
CreatingnewCupshelf2()inmain"
shelf.f2
(1);
cupshelf.f3
(1);
newInitialization();
LargeCup
(1)
LargeCup
(2)
Shelf()
f1
(1)
LargeCup(3)
LargeCup(4)
LargeCup(5)
Cupshelf()
f1
(2)
CreatingnewCupshelf1()inmain
CreatingnewCupshelf2()inmain
f2
(1)
f3
(1)
12、阅读以下程序,写出输出结果。
classPlate{
Plate(intmarker){
Plate("
classDesk{
staticPlateplate1=newPlate
(1);
Desk(){
Desk()"
plate2.f1
(1);
staticPlateplate2=newPlate
(2);
classBoard{
Plateplate3=newPlate(3);
staticPlateplate4=newPlate(4);
Board(){
Board()"
plate4.f1
(2);
staticPlateplate5=newPlate(5);
staticDeskdesk=newDesk();
BoardBoard=newBoard();
CreatingnewBoard()inmain"
newBoard();
Creating2newBoard()inmain"
desk.f2
(1);
//Board.f3
(1);
Plate
(1)
Plate
(2)
Desk()
CreatingnewBoard()inmain
Plate(4)
Plate(5)
Plate(3)
Board()
Creating2newBoard()inmain
13、阅读以下程序,写出输出结果。
classSwap{
voidsw1(Personx,Persony){
inta=y.id;
y.id=x.id;
x.id=a;
voidsw2(Personx,Persony){
Persone;
e=x;
y=x;
x=e;
publicclassPerson{
intid=0;
Person(intid){
this.id=id;
Swapcid=newSwap();
Personp1=newPerson(10);
Personp2=newPerson(11);
Personp3=newPerson(12);
Personp4=newPerson(13);
cid.sw1(p1,p2);
cid.sw2(p3,p4);
p1:
+p1.id+"
p2:
+p2.id);
p3:
+p3.id+"
p4:
+p4.id);
11p2:
10
12p4:
13
14、阅读以下程序,写出输出结果。
publicclassFoo{
publicstaticvoidmain(String[]args){
StringBuffera=newStringBuffer(“ThisisinSCUT”);
StringBufferb=newStringBuffer(“Twice”);
operate(a,b);
System.out.printIn(a+“,”+b);
staticvoidoperate(StringBufferx,StringBuffery){
x.append(y);
y=x;
ThisisinSCUTTwice,Twice
15、阅读以下程序,写出输出结果。
importstaticnet.mindview.util.Print.*;
classCandy{
static{print("
LoadingCandy"
classGum{
LoadingGum"
classCookie{
LoadingCookie"
publicclassSweetShop{
publicstaticvoidmain(String[]args){
print("
insidemain"
newCandy();
AftercreatingCandy"
try{
Class.forName("
Gum"
}catch(ClassNotFoundExceptione){
Couldn’tfind
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 华南理工大学java模拟题 华南理工大学 java 模拟