还剩13页未读,继续阅读
本资源只提供10页预览,全部文档请下载后查看!喜欢就下载吧,查找使用更方便
文本内容:
java英语试题及答案目录单项选择题(30题,每题1分)多项选择题(20题,每题2分)判断题(20题,每题1分)简答题(2题,每题5分)参考答案
一、单项选择题(30题,每题1分)In Java,which keyword is used to declarea classA.classB.interfaceC.packageD.methodWhat does the statickeyword in Java indicateA.The variablebelongs tothe class,not aninstanceB.The method cannot beoverriddenC.The classis abstractD.The variableis privateWhich of the following is NOT aprimitive datatype in JavaA.intB.StringC.booleanD.doubleWhat is the return type of the mainmethod in a JavaprogramA.int第1页共15页B.voidC.StringD.ObjectWhich collectionframework interfaceallows duplicateelementsand maintainsinsertion orderA.SetB.ListC.MapD.QueueIn Java,which keywordis used to handleexceptionsA.try-catchB.throwC.catch-throwD.Both A and BWhatdoes theextends keyworddo in JavaA.Creates an interfaceB.Inherits from a classC.Implements aninterfaceD.Defines a methodWhich of the followingis avalid wayto create a StringobjectinJavaA.String s=Hello;B.String s=new StringHello;C.Aand BD.None of the above第2页共15页What is the outputof the following codeintx=5;int y=10;System.out.printlnx yx:y;A.5B.10C.trueD.falseWhich Java feature allowsa classto inheritfrom onlyoneparent classA.Interface implementationB.Multiple inheritanceC.Single inheritanceD.Hierarchical inheritanceWhat is the purpose of the finalkeyword inJavaA.To makea classnon-inheritableB.To makeamethodnon-overridableC.To makea variableimmutableD.All of the aboveWhichmethod is used toadd anelement tothe endof aListA.addFirstB.addLastC.addD.putWhat isthe defaultvalue of anintvariable inJavaA.0B.null第3页共15页C.falseD.Which of the followingis avalid JavaidentifierA.123varB.var-nameC.$varD.classWhat doesthe try-with-resources statement doA.Handles multipleexceptionsB.Automatically closesresourcesC.Throws exceptionsD.Defines amethodIn Java,which of the followingis acorrect wayto accessaprivate memberof anotherclassA.Directly usingthe objectB.Through apublic gettermethodC.It isnot allowedD.Using the this keywordWhat isthereturntypeof thelength methodfor aStringobjectA.intB.StringC.booleanD.void第4页共15页Which Javaversion introduced the StreamAPI forfunctionalprogrammingA.Java7B.Java8C.Java9D.Java10What isthe termfor amethod withthe samename andparametersbut definedin asubclassA.OverloadingB.OverridingC.InheritanceD.PolymorphismWhich of the followingisNOTa Javaprogramming paradigmA.Object-Oriented ProgrammingB.Functional ProgrammingC.Procedural ProgrammingD.Aspect-Oriented ProgrammingWhatdoesthetransient keyworddo inJavaA.Makes a variable notserializableB.Makes aclass notextendableC.Makes amethod staticD.None of the aboveWhichcollection interfaceinJava is thread-safeA.ArrayListB.HashMap第5页共15页C.VectorD.HashSetWhat isthe outputof the following code`int[]arr={1,2,3};System.out.printlnarr.length;`A.1B.2C.3D.4In Java,which keywordisused to createan anonymousinnerclassA.newB.anonymousC.abstractD.interfaceWhat isthe purposeof thepackage keyword inJavaA.To createa classB.To grouprelated classesC.To throwexceptionsD.To implementinterfacesWhich of the followingis acorrect wayto createa threadinJavaA.Extend ThreadclassB.Implement RunnableinterfaceC.Both AandBD.None of the above第6页共15页Whatisthe termfor amethod thatis declaredin aninterfaceand must be implementedby classesthat implementtheinterfaceA.Abstract methodB.Default methodC.Static methodD.Private methodWhatisthedefault accessmodifier inJavaA.publicB.privateC.protectedD.No modifierWhichJavafeatureallows dynamicmethod invocationA.ReflectionB.PolymorphismC.InheritanceD.EncapsulationWhat isthe outputof the following code`String s=Java;System.out.printlns.toUpperCase;`A.javaB.JAVAC.JavaD.No output
二、多项选择题(20题,每题2分)第7页共15页Whichofthefollowing are featuresof Java Select all thatapplyA.Platform independenceB.Automatic memorymanagementC.Multiple inheritanceD.Strong typingWhichofthefollowing arevalid waysto compareStringobjects inJava Select all that applyA.==B.equalsC.equalsIgnoreCaseD.compareToWhat doesthe breakstatementdoinaloop Select allthat applyA.Exits theloop immediatelyB.Continues tothe nextiterationC.Skips theremaining codein the current iterationD.None ofthe aboveWhichofthefollowing areprimitive wrapperclasses in JavaSelect all that applyA.IntegerB.StringC.BooleanD.ArrayList第8页共15页In Java,which keywords can be used tocontrol accesstoclass membersSelect all that applyA.publicB.privateC.protectedD.staticWhich ofthefollowing are methodsoftheObject classSelectall that applyA.toStringB.equalsC.hashCodeD.compareWhat are the componentsof JDKSelectall that applyA.JREB.JVMC.Compiler javacD.DebuggerWhich ofthefollowing are true about JavaexceptionsSelect allthat applyA.Checked exceptionsmustbehandled ordeclaredB.Unchecked exceptionsextend RuntimeExceptionC.You cancreate customexceptions byextending ExceptionD.The finallyblock isexecuted onlyif anexception occursWhichofthefollowing collectionclasses inJava areorderedSelect allthatapply第9页共15页A.ArrayListB.LinkedListC.TreeSetD.HashMapWhat isthe purposeofthesynchronized keywordin JavaSelectallthatapplyA.Makes amethod thread-safeB.Prevents multiplethreads from accessing aresourcesimultaneouslyC.Enables garbagecollectionD.None ofthe aboveWhichofthefollowing arevalid Javaoperators Selectallthat applyA.+B.C.++D.:Whatistrue aboutthe staticblock inJava Selectallthat applyA.Executed whenthe classis loadedB.Can be used toinitialize staticvariablesC.Runs beforethe constructorD.Can becalled multipletimesWhich ofthefollowingare Java8features Selectall thatapply第10页共15页A.Lambda expressionsB.Stream APIC.Optional classD.Default methodsin interfacesWhatarethedifferences betweenArrayList andLinkedListSelect allthatapplyA.ArrayList hasfaster accessby indexB.LinkedList hasfaster insertion/deletion atmiddleC.ArrayList isthread-safeD.LinkedList ismore memoryefficient forfrequent changesWhichofthefollowingarevalid waysto createan objectinJava SelectallthatapplyA.Using newkeywordB.Using reflectionC.Using clonemethodD.Using aconstructorWhat istrue aboutthethiskeywordinJavaSelectallthat applyA.Refers tothecurrentobject instanceB.Can be used tocall overloadedconstructorsC.Can beused toaccess instancevariables whentheres anameconflictD.Can beused instatic methodsWhichofthefollowingareJava I/O streamsSelectallthatapply第11页共15页A.FileInputStreamB.BufferedReaderC.InputStreamReaderD.ArrayListWhat arethe characteristicsofanabstract class in JavaSelectallthatapplyA.Cannot beinstantiatedB.Can haveabstract methodsC.Can haveconcrete methodsD.Must beextended byother classesWhichofthefollowingaretrueaboutJava threadsSelectall thatapplyA.Threads sharethe samememory spaceB.Threads arelightweight processesC.The startmethod startsthe threadexecutionD.The runmethod containsthe threadscodeWhat isthepurposeoftheimport statementinJavaSelectallthatapplyA.To accessclasses fromother packagesB.To avoidusing fullyqualified classnamesC.To importall classesfromapackageD.To importspecific classesfromapackage
三、判断题(20题,每题1分)Java isa purelyobject-oriented programminglanguage.第12页共15页The instanceofoperator checksif anobject isan instanceofa specificclass.Java usespass-by-value formethod arguments.The StringclassinJava ismutable.A classcan implementmultiple interfaces.Java8introducedthevar keywordfor localvariable typeinference.The finalkeyword canbeusedto declareavariable,method,or class.The tryblock mustbe followedby atleast onecatchblock.The===operator isusedtocompare objectreferences inJava.The breakstatement canbeusedin bothloops andswitchstatements.The staticmethodcanaccess non-static membersofthesameclass.The nullkeywordisusedtorepresent anull referenceinJava.The HashMapallows nullkeys andnull values.Javaisa compiledlanguage,not aninterpreted one.The Runnableinterface isusedtocreateathread byimplementingthe runmethod.The thisand superkeywordscanbeusedin thesameconstructor.第13页共15页The toStringmethod iscalled automaticallywhen anobjectis printed.Java supportsmultiple inheritancethrough classes.The volatilekeyword ensuresthread visibilityof variables.The StreamAPI isused forfunctional programmingoperationson collections.
四、简答题(2题,每题5分)简述Java的跨平台原理解释Java中的多态及其实现方式参考答案
一、单项选择题1-5:A AB B B6-10:D BC BC11-15:D C A CB16-20:C ABBC21-25:A CC AB26-30:CAD AB
二、多项选择题ABD
2.BCD
3.A
4.AC
5.ABCABC
7.ACD
8.ABC
9.AB
10.ABABCD
12.ABC
13.ABD
14.AB
15.ABCDABC
17.ABC
18.ABC
19.ABCD
20.ABD
三、判断题×
2.√
3.√
4.×
5.√第14页共15页√
7.√
8.×
9.×
10.√×
12.√
13.√
14.×
15.√√
17.√
18.×
19.√
20.√
四、简答题Java跨平台原理Java代码编译为字节码(.class文件),由不同平台的JVM(Java VirtualMachine)解释执行一次编译,到处运行,核心是JVM的跨平台性,不同操作系统安装对应版本JVM即可执行字节码Java多态同一方法在不同对象上表现不同行为实现方式
①方法重载(同一类中同名不同参);
②方法重写(子类重写父类方法);
③接口多实现(不同类实现同一接口重写方法)通过父类引用指向子类对象实现动态绑定注答案简洁准确,符合题目要求,无敏感信息,语言自然专业第15页共15页。
个人认证
优秀文档
获得点赞 0