南财JAVA期末终极版doc文档格式.docx

上传人:b****1 文档编号:1369290 上传时间:2023-04-30 格式:DOCX 页数:24 大小:25.70KB
下载 相关 举报
南财JAVA期末终极版doc文档格式.docx_第1页
第1页 / 共24页
南财JAVA期末终极版doc文档格式.docx_第2页
第2页 / 共24页
南财JAVA期末终极版doc文档格式.docx_第3页
第3页 / 共24页
南财JAVA期末终极版doc文档格式.docx_第4页
第4页 / 共24页
南财JAVA期末终极版doc文档格式.docx_第5页
第5页 / 共24页
南财JAVA期末终极版doc文档格式.docx_第6页
第6页 / 共24页
南财JAVA期末终极版doc文档格式.docx_第7页
第7页 / 共24页
南财JAVA期末终极版doc文档格式.docx_第8页
第8页 / 共24页
南财JAVA期末终极版doc文档格式.docx_第9页
第9页 / 共24页
南财JAVA期末终极版doc文档格式.docx_第10页
第10页 / 共24页
南财JAVA期末终极版doc文档格式.docx_第11页
第11页 / 共24页
南财JAVA期末终极版doc文档格式.docx_第12页
第12页 / 共24页
南财JAVA期末终极版doc文档格式.docx_第13页
第13页 / 共24页
南财JAVA期末终极版doc文档格式.docx_第14页
第14页 / 共24页
南财JAVA期末终极版doc文档格式.docx_第15页
第15页 / 共24页
南财JAVA期末终极版doc文档格式.docx_第16页
第16页 / 共24页
南财JAVA期末终极版doc文档格式.docx_第17页
第17页 / 共24页
南财JAVA期末终极版doc文档格式.docx_第18页
第18页 / 共24页
南财JAVA期末终极版doc文档格式.docx_第19页
第19页 / 共24页
南财JAVA期末终极版doc文档格式.docx_第20页
第20页 / 共24页
亲,该文档总共24页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

南财JAVA期末终极版doc文档格式.docx

《南财JAVA期末终极版doc文档格式.docx》由会员分享,可在线阅读,更多相关《南财JAVA期末终极版doc文档格式.docx(24页珍藏版)》请在冰点文库上搜索。

南财JAVA期末终极版doc文档格式.docx

=5;

i=i+l)

{

System,out.printIn(,z第〃+i+〃次循环〃);

}

判断上述循环执行的次数。

7、Java语言不支持多重继承,但是通过接口可以实现多重继承的效果;

Java程序有两类:

Application和Applet;

Java中类的方法可以使用public或者private或者protected进行修饰,也可以不适用任何修饰符。

8、同一个类的实例(对象)之所以能相互区分,是因为他们占用不同的内存单元,但是静态成员共享相同的内存空间。

9、++、--运算符

10、要创建对象,必须先定义类;

对象的构成包括属性和方法,但是不是必须的,可以没有属性,也可以没有方法。

属性可以是简单变量,也可以是一个复杂变量

(即对象)

11、标识符的命名规则

12、Java中,要编译一个类使用javac.exe(编译器)命令,耍解释执行一个类使用java,exe命令(虚拟机)。

13、Java语言借鉴了C语言、C++语言的很多语法特征,其最主要的特点就是跨平台。

14、Java语言是区分大小写的;

所有变量必须先定义才能使用;

Java是强类型语言,即变量类型必须要明确定义;

Java中一条语句的结束必须要使用分号;

源文件的扩展名为.java,经过编译以后得到字节码文件,扩展名为.class。

一个源文件中可以定义多个类,但是其中只能有一个class是publicclass,而且publicclass的名字必须和源文件的名字相同。

一个源文件编译以后,可能会得到多个字节码文件,即源文件中的每个类都会产生一个对应的字节码文件。

15>

double和Double是不同的类型。

double是简单类型,仅仅存储了一个值;

而Double是对象类型,是double的封装类,除了存储值以外,还提供一些方法,比如Double.parseDoubleC12.34〃)可以从字符串〃12.34〃中得到数值12.34。

16、P35类型的自动转换。

17、构造函数的调用时机:

在使用new创建对象时自动调用。

18、执行for(inti=0,j=3;

j<

6;

j+=2)i=i+j;

后,i的值是?

19、复合赋值运算符:

+二、-二、村、/二表示什么意义?

20、循环语句for(inti二0;

true;

i++);

是否正确呢?

是正确的。

循环语句的循环体可以为空语句;

循环条件为true,则表示为永久循环。

21、在继承中,子类将继承父类的所有属性和方法。

22、一个类中可以有多个构造函数,这多个构造函数具有相同的名字(即类名),可以具有不同的参数,通过参数的不同进行区分(即构造函数的重载)。

23、八进制整数、十六进制整数的表示方法。

24、数组的定义:

数组是具有相同类型数据元素的集合。

25、字符类型变量的编码是Unicode编码,英文字母的编码是连续的,数字的编码也是连续的。

字符'

A'

和字符'

a'

的编码分别是多少?

二、填空题

1、Java中的八种简单数据类型是哪些?

各自的长度是多少字节?

2、类的定义方法、对象如何创建

3、数组如何创建?

数组中元素的个数使用什么属性表示?

length

4、1/2跟1.0/2的区别是什么?

5、main方法的原型一般为:

publicstaticvoidmain(String[]args)

其中参数args为String[],即String类型的数组,在这个数组中保存的就是用户通过命令行传入的参数,比如我们使用java执行一个类He11eWorld时,语法如下:

javaIlclloWorldtlt2123

在上面的命令中,java指的是java,exe,是用于执行一个java程序的java解释器程序,He11eWorld是要被执行的java类,tl、12、123是传入的三个参数,将被保存在Sting类型的数组args中,即args[0]为"

tl”,args[l]为"

t2”,args[2]为〃123〃。

如果需要将某个字符串转换为数值,则需要使用下面的语句:

inti=Integer,parselnt(〃123〃);

6、Java中的流程控制结构主要有:

顺序结构、分支结构、循环结构

7、Java语言中的内存管理,不需要程序员编程实现。

Java本身提供了垃圾收集机制,可以简化内存的管理。

8、字符串是使用双引号引导的一串字符,可以是0个字符、1个字符或者多个字符;

字符串的长度可以使用字符串对象的length方法(不是length属性)得到:

“abc”长度为3

“abc\n”的长度呢?

(不是5!

9、要定义一个类所属于的包,使用package语句进行定义;

要包含/引用某个包中的类,则需要使用import语句。

比如,要使用java.io包中的所有类,则应该在程序开始处加上:

importjava.io.*;

要创建一个包myPackagc,则应使用:

packagemyPackage;

10、接口的定义使用interface;

抽象类的定义使用abstract关键字;

实现一个接曰使用implements;

继承一个基类使用extendso

11、两个整数相除,结果是怎样的?

比如3/8值为?

12、设有数组定义:

intMylntArrayE]={10,20,30,40,50,60,70);

则执行以下几个语句后的输出结果是?

ints=0;

for(inti=0;

i<

MylntArray.length;

i++)

if(i%2二二1)

s+=MylntArray[i];

System,out.println(s);

13、取模运算符是什么?

表示的意义是什么?

14、数组x定义如下:

intx[][]=newint[5][2];

则x[0].length的值为是?

15、Java开发环境的建立,一般需要设置path和classpath两个环境变量。

16、double型变量与byte型变量进行减法运算,运算的结果类型是什么类型?

涉及到的知识点:

自动类型转换。

17、Java中的字符使用的是16进制的Unicode编码。

18、Java中采用单重继承,而不是多重继承。

其中java.lang.Object是所有类的基类。

19、假设x=13,y=4,则表达式x%y!

=0的值是多少?

值的类型是什么?

三、名词解释

1.short-circuitoperator:

P90

Ifoneoftheoperandsofan&

&

operatorisfalse,theexpressionisfalse;

ifoneoftheoperandsofanoperatoristrue,theexpressionistrue.Javausesthesepropertiestoimprovetheperformanceoftheseoperators.Whenevaluatingpl&

p2,Javafirstevaluatesplandthen,ifplistrue,evaluatesp2;

ifplisfalse,itdocsnotevaluatep2.Whenevaluatingpl||p2,Javafirstevaluatesplandthen,ifplisfalse,evaluatesp2;

ifplistrue,itdoesnotevaluatep2.Therefore,&

isreferredtoastheconditionalorshort-circuitANDoperator,and||isreferredtoastheconditionalorshort-circuitORoperator.

2.methodoverloading:

P169

Twomethodshavethesamenamebutdifferentparameterlistswithinoneclass.TheJavacompilerdetermineswhichmethodisusedbasedonthemethodsignature.

3.staticvariable:

P278

Staticvariables,alsoknownasclassvariables,storevaluesforthevariablesinacommonmemorylocation.Becauseofthiscommonlocation,ifoneobjectchangesthevalueofastaticvariable,allobjectsofthesameclassarcaffected.

4.constructors:

P270

Constructorsareaspecialkindofmethod.Theyhavethreepeculiarities:

1)Aconstructormusthavethesamenameastheclassitself.

2)Constructorsdonothaveareturntype—notevenvoid.

3)Constructorsareinvokedusingthenewoperatorwhenanobjectiscreated.Constructorsplaytheroleofinitializingobjects.

Likeregularmethods,constructorscanbeoverloaded,makingiteasytoconstructobjectswithdifferentinitialdatavalues.

5.pass-by-value:

P163

Whenyouinvokeamethodwithaparameter,thevalueoftheargumentispassedtotheparameter.Thisisreferredtoaspass-by-value.Iftheargumentisavariableratherthana1iteralvalue,thevalueofthevariableispassedtotheparameter.Thevariableisnotaffected,regardlessofthechangesmadetotheparameterinsidethemethod.

6.object:

P264

Anobjectrepresentsanentityintherealworldthatcanbedistinctlyidentified.Anobjecthasauniqueidentity,state,andbehavior.

1)Thestateofanobject(alsoknownasitspropertiesorattributes)isrepresentedbydatafieldswiththeircurrentvalues.

2)Thebehaviorofanobject(alsoknownasitsactions)isdefinedbymethods.Toinvokeamethodonanobjectistoasktheobjecttoperforinanaction.

Objectsofthesametypearedefinedusingacommonclass.Aclassisatemplate,blueprint,orcontractthatdefineswhatanobject"

sdatafieldsandmethodswillbe.Anobjectisaninstanceofaclass.

7.array:

P198

Anarrayisadatastructurewhichstoresafixed-sizesequentialcollectionofelementsofthesametype.

8.datafieldencapsulation:

P283Topreventdirectmodificationsofdatafields,youshoulddeclarethedatafieldsprivate,usingtheprivatemodifier.Thisisknownasdatafieldencapsulation.

Aprivatedatafieldcannotbeaccessedbyanobjectfromoutsidetheclassthatdefinestheprivatefield.Butoftenaclientneedstoretrieveandmodifyadatafield.Tomakeaprivatedatafieldaccessible,provideagetmethodtoreturnitsvalue.Toenableaprivatedatafieldtobeupdated,provideasetmethodtosetanewvalue.

四、阅读程序题

1、

classA

Stringsi,s2;

A(Stringsll,Strings22)//此为构造函数

sl=sll;

s2=s22;

publicStringtoString()

returnsl+s2+“你好”;

classT

〃将调用类A的构造函数,并将si初始化为“m”,将s2初始化为“n”

Aa=newA("

m”,"

n”);

a.toStringO;

//调用对象a的toString方法,将输出“mn你好”

2、数组中元素累加的实现,%运算符的作用

publicclasst

publicstaticvoidmain(Stringargs[])

inti,s=0;

inta[]=(1,2,3,4,5,6,7,8,9);

for(i=0;

a.length;

i++)

if(a[i]%2!

=0)s+=a[i];

System,out.printin(〃s二〃+s);

3、

publicclassPerson

intage;

Stringname;

〃构造函数,将age和name设置为指定的值

publicPerson(inta,Stringn)

age=a;

name二n;

publicvoidhi()

System,out.printin(uhi,mynameis:

v+name+"

,niyageis"

+age);

newPerson(20,“张三”).hi();

4、数组的遍历:

将数组中元素逐个输出的方法。

5、System,out.print()与System,out.printlnO的区别:

System,out.print():

输出参数指定的内容后不会换行,还是在原来的那一行

System,out.printlnO:

输出参数指定的内容后将换一行,下一次输出将从下一行开始

嵌套循环的理解,例如:

publicclasstest5

inti,j;

for(i=0;

8;

i++)

for(j=0;

j<

=2*i;

j++)

System.out.print(〃##〃);

System,out.printin();

上述代码执行后,输出的结果是?

6^

intx=3,y=10;

doublez=l.23;

floatw=1.234f;

//这里为什么要加f?

?

booleanflag二x>

y;

System,out.printin(〃x>

y=〃+flag);

flag=z>

w;

System,out.printin(〃z>

w==〃+flag);

7、

publicclasstest2

try

method();

catch(Exceptione)

System,out.println(〃A〃);

finally

System,out.printin(〃B〃);

staticvoidmethod()

wrench();

System,out.printin(〃C〃);

catch(ArithmcticExccptionc)

System,out.printin(〃D〃);

System,out.println(〃E〃);

System,out.printin(〃F〃);

staticvoidwrench()

thrownewNullPointerException();

IJ

8、

inta[]=(10,20,30,40,50,60,70);

calculate(a,a[6]);

System,out.printin(/zthevalueofa[0]is〃+a[0]);

System,out.printin(z/thevalueofa[6]is〃+a[6]);

}staticintcalculate(intx[],inty)

for(inti=1;

x.length;

i++)

if(y<

x.length)

x[i]=x[i-1]+2;

returnx[0];

9、

publicclassBook

staticStringname;

intprice;

publicvoidsetPrice(intp)

price=p;

publicvoidout()

+price);

System,out.println("

书名是:

”+name+"

价格是:

”)publicstaticvoidmain(String[]args)

Book.name="

Java语言程序设计”

Bookb=newBook();

b.setPrice(20);

b.out();

10、字符a的ASCII编码是97、字母A的ASCII编码是65publicclasst

publicstaticvoidmain(Stringarge[])

inti=0;

for(charch=97;

ch<

115;

ch++,i++)

if(i%4=0)

System,out.printin(,z〃);

System,out.print(〃\t〃+ch);

11、Switch结构的执行流程

12、嵌套循环的提前退出:

break、continue的应用及其区别。

13、

publicclassAnimal

Stringtype二〃Dog:

\t〃;

Stringname=Tom;

Animalt=newAnimal();

System,out.print(t.type);

System,out.println(t.name);

14、考察知识点:

循环、参数的传递

publicclassLoopTest

publicstaticvoidm

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 人文社科 > 法律资料

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2