欢迎来到天天文库
浏览记录
ID:39507524
大小:69.50 KB
页数:14页
时间:2019-07-04
《java面试题和答案(英文版)》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、Java面试题和答案(英文版)Q:WhatisthedifferencebetweenanInterfaceandanAbstractclass?A:Anabstractclasscanhaveinstancemethodsthatimplementadefaultbehavior.AnInterfacecanonlydeclareconstantsandinstancemethods,butcannotimplementdefaultbehaviorandallmethodsareimplicitlyabstract.Aninterfacehasallpublic
2、membersandnoimplementation.Anabstractclassisaclasswhichmayhavetheusualflavorsofclassmembers(private,protected,etc.),buthassomeabstractmethods.Q:WhatisthepurposeofgarbagecollectioninJava,andwhenisitused?A:Thepurposeofgarbagecollectionistoidentifyanddiscardobjectsthatarenolongerneededbya
3、programsothattheirresourcescanbereclaimedandreused.AJavaobjectissubjecttogarbagecollectionwhenitbecomesunreachabletotheprograminwhichitisused.Q:Describesynchronizationinrespecttomultithreading.A:Withrespecttomultithreading,synchronizationisthecapabilitytocontroltheaccessofmultiplethrea
4、dstosharedresources.Withoutsynchonization,itispossibleforonethreadtomodifyasharedvariablewhileanotherthreadisintheprocessofusingorupdatingsamesharedvariable.Thisusuallyleadstosignificanterrors.Q:Explaindifferentwayofusingthread?A:Thethreadcouldbeimplementedbyusingrunnableinterfaceorbyi
5、nheritingfromtheThreadclass.Theformerismoreadvantageous,'causewhenyouaregoingformultipleinheritance..theonlyinterfacecanhelp.Q:Whatarepassbyreferenceandpassbyvalue?A:PassByReferencemeansthepassingtheaddressitselfratherthanpassingthevalue.PassbyValuemeanspassingacopyofthevaluetobepassed
6、.Q:WhatisHashMapandMap?A:MapisInterfaceandHashmapisclassthatimplementsthat.Q:DifferencebetweenHashMapandHashTable?A:TheHashMapclassisroughlyequivalenttoHashtable,exceptthatitisunsynchronizedandpermitsnulls.(HashMapallowsnullvaluesaskeyandvaluewhereasHashtabledoesntallow).HashMapdoesnot
7、guaranteethattheorderofthemapwillremainconstantovertime.HashMapisunsynchronizedandHashtableissynchronized.Q:DifferencebetweenVectorandArrayList?A:Vectorissynchronizedwhereasarraylistisnot.Q:DifferencebetweenSwingandAwt?A:AWTareheavy-weightcomponenets.Swingsarelight-weightcomponents.H
此文档下载收益归作者所有