全民快乐8

你当前所在位置:全民快乐8 > IT就业问题 > Java面试题及答案(19/19)——JVM

Java面试题及答案(19/19)——JVM

194. 说一下 jvm 的主要组成部分?及其作用?

 

● LEIJIAZAIQI(ClassLoader)

全民快乐8● YUNXINGSHISHUJUQU(Runtime Data Area)

全民快乐8● ZHIXINGYINQING(Execution Engine)

● BENDIKUJIEKOU(Native Interface)

 

全民快乐8ZUJIANDEZUOYONG: SHOUXIANTONGGUOLEIJIAZAIQI(ClassLoader)HUIBA Java DAIMAZHUANHUANCHENGZIJIEMA,YUNXINGSHISHUJUQU(Runtime Data Area)ZAIBAZIJIEMAJIAZAIDAONEICUNZHONG,ERZIJIEMAWENJIANZHISHI JVM DEYITAOZHILINGJIGUIFAN,BINGBUNENGZHIJIEJIAOGEDICENGCAOZUOXITONGQUZHIXING,YINCIXUYAOTEDINGDEMINGLINGJIEXIQIZHIXINGYINQING(Execution Engine),JIANGZIJIEMAFANYICHENGDICENGXITONGZHILING,ZAIJIAOYOU CPU QUZHIXING,ERZHEIGEGUOCHENGZHONGXUYAODIAOYONGQITAYUYANDEBENDIKUJIEKOU(Native Interface)LAISHIXIANZHENGGECHENGXUDEGONGNENG。

 

195. 说一下 jvm 运行时数据区?

 

● CHENGXUJISHUQI

● XUNIJIZHAN

● BENDIFANGFAZHAN

● DUI

● FANGFAQU

 

YOUDEQUYUSUIZHEXUNIJIJINCHENGDEQIDONGERCUNZAI,YOUDEQUYUZEYILAIYONGHUJINCHENGDEQIDONGHEJIESHUERCHUANGJIANHEXIAOHUI。

 

196. 说一下堆栈的区别?

 

全民快乐8● ZHANNEICUNCUNCHUDESHIJUBUBIANLIANG,ERDUINEICUNCUNCHUDESHISHITI;

 

● ZHANNEICUNDEGENGXINSUDUYAOKUAIYUDUINEICUN,YINWEIJUBUBIANLIANGDESHENGMINGZHOUQIHENDUAN;

 

● ZHANNEICUNCUNFANGDEBIANLIANGSHENGMINGZHOUQIYIDANJIESHUJIUHUIBEISHIFANG,ERDUINEICUNCUNFANGDESHITIHUIBEILAJIHUISHOUJIZHIBUDINGSHIDEHUISHOU。

 

197. 队列和栈是什么?有什么区别?

 

全民快乐8● DUILIEHEZHANDOUSHIBEIYONGLAIYUCUNCHUSHUJUDE。

全民快乐8● DUILIEYUNXUXIANJINXIANCHUJIANSUOYUANSU,DANYEYOULIWAIDEQINGKUANG,Deque JIEKOUYUNXUCONGLIANGDUANJIANSUOYUANSU。

● ZHANHEDUILIEHENXIANGSI,DANTAYUNXINGDUIYUANSUJINXINGHOUJINXIANCHUJINXINGJIANSUO。

 

198. 什么是双亲委派模型?

 

ZAIJIESHAOSHUANGQINWEIPAIMOXINGZHIQIANXIANSHUOXIALEIJIAZAIQI。DUIYURENYIYIGELEI,DOUXUYAOYOUJIAZAITADELEIJIAZAIQIHEZHEIGELEIBENSHENYITONGQUELIZAI JVM ZHONGDEWEIYIXING,MEIYIGELEIJIAZAIQI,DOUYOUYIGEDULIDELEIMINGCHENGKONGJIAN。LEIJIAZAIQIJIUSHIGENJUZHIDINGQUANXIANDINGMINGCHENGJIANG class WENJIANJIAZAIDAO JVM NEICUN,RANHOUZAIZHUANHUAWEI class DUIXIANG。

 

LEIJIAZAIQIFENLEI:

 

● QIDONGLEIJIAZAIQI(Bootstrap ClassLoader):SHIXUNIJIZISHENDEYIBUFEN,YONGLAIJIAZAIJava_HOME/lib/MULUZHONGDE,HUOZHEBEI -Xbootclasspath CANSHUSUOZHIDINGDELUJINGZHONGBINGQIEBEIXUNIJISHIBIEDELEIKU;

 

● QITALEIJIAZAIQI:KUOZHANLEIJIAZAIQI(Extension ClassLoader):FUZEJIAZAI<java_home style=“box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; outline: 0px !important;”>\lib\extMULUHUOJava. ext. dirsXITONGBIANLIANGZHIDINGDELUJINGZHONGDESUOYOULEIKU;</java_home>

YINGYONGCHENGXULEIJIAZAIQI(Application ClassLoader)。FUZEJIAZAIYONGHULEILUJING(classpath)SHANGDEZHIDINGLEIKU,WOMENKEYIZHIJIESHIYONGZHEIGELEIJIAZAIQI。YIBANQINGKUANG,RUGUOWOMENMEIYOUZIDINGYILEIJIAZAIQIMORENJIUSHIYONGZHEIGEJIAZAIQI。

 

双亲委派模型:如果一个类加载器收到了类加载的请求,它首先不会自己去加载这个类,而是把这个请求委派给父类加载器去完成,每一层的类加载器都是如此,这样所有的加载请求都会被传送到顶层的启动类加载器中,只有当父加载无法完成加载请求(它的搜索范围中没找到所需的类)时,子加载器才会尝试去加载类。

 

199. 说一下类加载的执行过程?

 

LEIJIAZAIFENWEIYIXIA 5 GEBUZHOU:

 

全民快乐8● JIAZAI:GENJUCHAZHAOLUJINGZHAODAOXIANGYINGDE class WENJIANRANHOUDAORU;

● JIANCHA:JIANCHAJIAZAIDE class WENJIANDEZHENGQUEXING;

● ZHUNBEI:JILEIZHONGDEJINGTAIBIANLIANGFENPEINEICUNKONGJIAN;

全民快乐8● JIEXI:XUNIJIJIANGCHANGLIANGCHIZHONGDEFUHAOYINYONGTIHUANCHENGZHIJIEYINYONGDEGUOCHENG。FUHAOYINYONGJIULIJIEWEIYIGEBIAOSHI,ERZAIZHIJIEYINYONGZHIJIEZHIXIANGNEICUNZHONGDEDIZHI;

● CHUSHIHUA:DUIJINGTAIBIANLIANGHEJINGTAIDAIMAKUAIZHIXINGCHUSHIHUAGONGZUO。

 

200. 怎么判断对象是否可以被回收?

 

YIBANYOULIANGZHONGFANGFALAIPANDUAN:

 

● YINYONGJISHUQI:WEIMEIGEDUIXIANGCHUANGJIANYIGEYINYONGJISHU,YOUDUIXIANGYINYONGSHIJISHUQI +1,YINYONGBEISHIFANGSHIJISHU -1,DANGJISHUQIWEI 0 SHIJIUKEYIBEIHUISHOU。TAYOUYIGEQUEDIANBUNENGJIEJUEXUNHUANYINYONGDEWENTI;

 

● KEDAXINGFENXI:CONG GC Roots KAISHIXIANGXIASOUSUO,SOUSUOSUOZOUGUODELUJINGCHENGWEIYINYONGLIAN。DANGYIGEDUIXIANGDAO GC Roots MEIYOURENHEYINYONGLIANXIANGLIANSHI,ZEZHENGMINGCIDUIXIANGSHIKEYIBEIHUISHOUDE。

 

201. java 中都有哪些引用类型?

 

● QIANGYINYONG

● RUANYINYONG

● RUOYINYONG

全民快乐8● XUYINYONG(YOULINGYINYONG/HUANYINGYINYONG)

 

202. 说一下 jvm 有哪些垃圾回收算法?

 

全民快乐8● BIAOJI-QINGCHUSUANFA

● BIAOJI-ZHENGLISUANFA

● FUZHISUANFA

● FENDAISUANFA

 

203. 说一下 jvm 有哪些垃圾回收器?

 

● Serial:ZUIZAODEDANXIANCHENGCHUANXINGLAJIHUISHOUQI。

 

● Serial Old:Serial LAJIHUISHOUQIDELAONIANBANBEN,TONGYANGYESHIDANXIANCHENGDE,KEYIZUOWEI CMS LAJIHUISHOUQIDEBEIXUANYUAN。

 

● ParNew:SHI Serial DEDUOXIANCHENGBANBEN。

 

全民快乐8● Parallel HE ParNew SHOUJIQILEISISHIDUOXIANCHENGDE,DAN Parallel SHITUNTULIANGYOUXIANDESHOUJIQI,KEYIXISHENGDENGDAISHIJIANHUANQUXITONGDETUNTULIANG。

 

● Parallel Old SHI Parallel LAOSHENGDAIBANBEN,Parallel SHIYONGDESHIFUZHIDENEICUNHUISHOUSUANFA,Parallel Old SHIYONGDESHIBIAOJI-ZHENGLIDENEICUNHUISHOUSUANFA。

 

全民快乐8● CMS:YIZHONGYIHUODEZUIDUANTINGDUNSHIJIANWEIMUBIAODESHOUJIQI,FEICHANGSHIYONG B/S XITONG。

 

● G1:YIZHONGJIANGUTUNTULIANGHETINGDUNSHIJIANDE GC SHIXIAN,SHI JDK 9 YIHOUDEMOREN GC XUANXIANG。

 

204. 详细介绍一下 CMS 垃圾回收器?

 

全民快乐8CMS SHIYINGWEN Concurrent Mark-Sweep DEJIANCHENG,SHIYIXISHENGTUNTULIANGWEIDAIJIALAIHUODEZUIDUANHUISHOUTINGDUNSHIJIANDELAJIHUISHOUQI。DUIYUYAOQIUFUWUQIXIANGYINGSUDUDEYINGYONGSHANG,ZHEIZHONGLAJIHUISHOUQIFEICHANGSHIHE。ZAIQIDONG JVM DECANSHUJIASHANG“-XX:+UseConcMarkSweepGC”LAIZHIDINGSHIYONG CMS LAJIHUISHOUQI。

 

CMS SHIYONGDESHIBIAOJI-QINGCHUDESUANFASHIXIANDE,SUOYIZAI gc DESHIHOUHUICHANSHENGDALIANGDENEICUNSUIPIAN,DANGSHENGYUNEICUNBUNENGMANZUCHENGXUYUNXINGYAOQIUSHI,XITONGJIANGHUICHUXIAN Concurrent Mode Failure,LINSHI CMS HUICAIYONG Serial Old HUISHOUQIJINXINGLAJIQINGCHU,CISHIDEXINGNENGJIANGHUIBEIJIANGDI。

 

205. 新生代垃圾回收器和老生代垃圾回收器都有哪些?有什么区别?

 

全民快乐8● XINSHENGDAIHUISHOUQI:Serial、ParNew、Parallel Scavenge

全民快乐8● LAONIANDAIHUISHOUQI:Serial Old、Parallel Old、CMS

全民快乐8● ZHENGDUIHUISHOUQI:G1

 

XINSHENGDAILAJIHUISHOUQIYIBANCAIYONGDESHIFUZHISUANFA,FUZHISUANFADEYOUDIANSHIXIAOLVGAO,QUEDIANSHINEICUNLIYONGLVDI;LAONIANDAIHUISHOUQIYIBANCAIYONGDESHIBIAOJI-ZHENGLIDESUANFAJINXINGLAJIHUISHOU。

 

206. 简述分代垃圾回收器是怎么工作的?

 

FENDAIHUISHOUQIYOULIANGGEFENQU:LAOSHENGDAIHEXINSHENGDAI,XINSHENGDAIMORENDEKONGJIANZHANBIZONGKONGJIANDE 1/3,LAOSHENGDAIDEMORENZHANBISHI 2/3。

 

XINSHENGDAISHIYONGDESHIFUZHISUANFA,XINSHENGDAILIYOU 3 GEFENQU:Eden、To Survivor、From Survivor,TAMENDEMORENZHANBISHI 8:1:1,TADEZHIXINGLIUCHENGRUXIA:

 

● BA Eden + From Survivor CUNHUODEDUIXIANGFANGRU To Survivor QU;

 

全民快乐8● QINGKONG Eden HE From Survivor FENQU;

 

● From Survivor HE To Survivor FENQUJIAOHUAN,From Survivor BIAN To Survivor,To Survivor BIAN From Survivor。

 

全民快乐8MEICIZAI From Survivor DAO To Survivor YIDONGSHIDOUCUNHUODEDUIXIANG,NIANLINGJIU +1,DANGNIANLINGDAODA 15(MORENPEIZHISHI 15)SHI,SHENGJIWEILAOSHENGDAI。DADUIXIANGYEHUIZHIJIEJINRULAOSHENGDAI。

 

LAOSHENGDAIDANGKONGJIANZHANYONGDAODAMOUGEZHIZHIHOUJIUHUICHUFAQUANJULAJISHOUHUI,YIBANSHIYONGBIAOJIZHENGLIDEZHIXINGSUANFA。YISHANGZHEIXIEXUNHUANWANGFUJIUGOUCHENGLEZHENGGEFENDAILAJIHUISHOUDEZHENGTIZHIXINGLIUCHENG。

 

207. 说一下 jvm 调优的工具?

 

JDK ZIDAILEHENDUOJIANKONGGONGJU,DOUWEIYU JDK DE bin MULUXIA,QIZHONGZUICHANGYONGDESHI jconsole HE jvisualvm ZHEILIANGKUANSHITUJIANKONGGONGJU。

 

● jconsole:YONGYUDUI JVM ZHONGDENEICUN、XIANCHENGHELEIDENGJINXINGJIANKONG;

 

全民快乐8● jvisualvm:JDK ZIDAIDEQUANNENGFENXIGONGJU,KEYIFENXI:NEICUNKUAIZHAO、XIANCHENGKUAIZHAO、CHENGXUSISUO、JIANKONGNEICUNDEBIANHUA、gc BIANHUADENG。

 

208. 常用的 jvm 调优的参数都有哪些?

 

全民快乐8-Xms2g:CHUSHIHUATUIDAXIAOWEI 2g;

-Xmx2g:DUIZUIDANEICUNWEI 2g;

-XX:NewRatio=4:SHEZHINIANQINGDEHELAONIANDAIDENEICUNBILIWEI 1:4;

全民快乐8-XX:SurvivorRatio=8:SHEZHIXINSHENGDAI Eden HE Survivor BILIWEI 8:2;

全民快乐8-XX:+UseParNewGC:ZHIDINGSHIYONG ParNew + Serial Old LAJIHUISHOUQIZUHE;

-XX:+UseParallelOldGC:ZHIDINGSHIYONG ParNew + ParNew Old LAJIHUISHOUQIZUHE;

-XX:+UseConcMarkSweepGC:ZHIDINGSHIYONG CMS + Serial Old LAJIHUISHOUQIZUHE;

全民快乐8-XX:+PrintGC:KAIQIDAYIN gc XINXI;

-XX:+PrintGCDetails:DAYIN gc XIANGXIXINXI。


课程预约

全民快乐8

全民快乐8