实例介绍
Oracle公司 Java8 Java SE 8 Programmer I 认证考试1z0-808题库 总167题
public static void main(string[] args)t Chort s1 =2005 工 nteger s2=400 Long s3=(long) s1 t s2 //line n1 String s4 =(String) (s3* s2) line 12 System. out. println(Sum is+ s4) What is the result? A. Sum is 600 B. Compilation fails at line n 1 C. Compilation fails at line n2 D. A Class castException is thrown at line n 1 E. A Class CastException is thrown at line n2 Correct Answer: c Section: (none Explanation Explanation/Reference: QUESTION 4 What is the name of the Java concept that uses access modifiers to protect variables and hide them within a class? A. Encapsulation B. Inheritance C. Abstraction D. Instantiation E. Polymorphism Correct answer:a Section:(none) Explanation Explanation /Reference Explanation Using the private modifier is the main way that an object encapsulates itself and hide data from the outside world Referencehttp://www.tutorialspoint.com/iavaliavaaccessmodifiers.htm QUESTION 5 Given the code fragment a上g七 ract. c1as卫1anet protected void revolve( t //line n1 点上 stract i○ id rotate(〕F //line n2 class earth extends planet i v③idreⅴ。1ve() //line n3 protected void rotate() i // line n 4 Which two modifications, made independently, enable the code to compile? A. Make the method at line n1 public B. Make the method at line n2 public C. Make the method at line n3 public D. Make the method at line n3 protected E. Make the method at line n4 public Correct Answer: CD Section:(none Explanation Explanation/Reference QUESTION 6 Given class vehicle i String type =40 int maxspeed =100 i Vehicle (string typer int maxspeed) this type = typei this. maxspeed maxspeedp class car extends vehicle i string trans i Car (string trans)[ /1ine n1 this, trans trans i car(string typer int marspeed, string trans) i super (type, maxSpeed)i this〔 trans); i/line n2 And given the code fragment 7. Car cl =new Car(Auto) 8. Car c2 new Car(4T, 150rfanual) 9. System. out. printIn(cl type tt cl. nmaxspeed -m+ cl. trans 10. System. out. println(c2 type tt az5p合e以-"甲 C2. trans)i What is the result? A. 4W 100 Auto 4∨150 Manua B. Null o auto 4W 150 Manual C. Compilation fails only at line n 1 D. Compilation fails only at line n2 E. Compilation fails at both line n 1 and line n2 Correct Answer:c Section: (none Explanation Explanation/Reference: QUESTION 7 Given the code fragment public static void main(string[] args) stringBuilder sh= new stringBuilder(5) string s =; fsh.equa1s(s〕) System. out. println(Match 1); else if(sb. tostring(.equals(s tostring()) System. out. println(Match 2) y else i Systemm out println( No Match") What is the result? A. Match 1 b. Match 2 C. No Match D. A NullPointerEXception is thrown at runtime Correct answer: B Section: (none Explanation Explanation/Reference: QUESTION 8 Giyen Pub1 ic static void mmain〔 string[]arg当) 七 ring ta AI 七a=ta, concat〔"E" String th =C 七a=七a.C○nCat(七b) 七.ep1ace〔"c;D"; 七a=a.C○nCat〔七b) Systenm, out. println(ta)i What is the result? A ABCD B. ACD C, ABCC D.ABD E ABDC Correct Answer: C Section :(none) Explanation Explanation/Reference: ta replace (C, D"); a= ta replace (C, d) 则选E QUESTION 9 Given class cD i lnt FF CD(int r)i 七h r=if C1as吕Dⅴ D eAten吕CD{ Int c DYD〔 Lnt r int c i line n1 And given the code fragment dVd dvd neW DVD(10,20); Which code fragment should you use at line n 1 to instantiate the dvd object successfully? A)superr =r 七h1s.c C B)super(r) this C) super(r) 七hs,C=C; 七h1 e11per(c〕 A. Option A B. Option B C. Option c D. Option d Correct Answer: C Section:(none Explanation Explanation/Reference: QUESTION 10 Given the code fragment lnt al 1;2;3 for (xXx i System.out. print (ale])i } Which option can replace xxx to enable the code to print 135? A. int e=0: e<=4: 0++ B.inte=0;e≤5;e+=2 C.inte=1;e<=5;e+=1 D. int e=1; e<5; 8+=2 Correct answer: B Section: (none) Explanation Explanation/Reference: QUESTION 11 Which statement best describes encapsulation? A. Encapsulation ensures that classes can be designed so that only certain fields and methods of an object are accessible from other objects B. Encapsulation ensures that classes can be designed so that their methods are inheritable C. Encapsulation ensures that classes can be designed with some fields and methods declared as abstract D. Encapsulation ensures that classes can be designed so that if a method has an argument My T ype x, any subclass of Mytype can be passed to that metho Correct Answer:A Section: (none) Explanation Explanation/Reference QUESTION 12 Given the code fragment from three files: alesMan. java package sales pub11cc1a三SSa1e≥Man Product. java package sales products Pub111a吕吕P○d1ct{} Market. java 1. package market: 2 insert code her 3. public class usMarket i 4 Salesman srmp product Which code fragment, when inserted at line 2, enables the code to compile? C Import sales.* CB)import java. sales products. cC) import sales import sales products CD) irnport sa1es,大; import products.*i C Import sales import sales, products. *i A. Option A B. Option B C. Option c D. Option D E. Option E Correct Answer: E Section: (none Explanation Explanation/Reference QUESTION 13 Given the following class public class CheckingAccount i public int amount public CheckingAccount (int amount)i this. amount amount public int getAmount ()i eturn ar01n七 public void changeAmmount (int x)[ mount十=x And given the following main method located in another class oubl-c static vcid main (string[l args)i Checkingacccunt acct =new checkingAccount ((int)(rath. random*1030))i system. out. println(acct getAmount Which three lines, when inserted independently at line n1, cause the program to print a 0 balance? A. this amount = o B. amount =0: C. acct(O) D. acct, amount =0 E. acct getAmount (=0 F. acct. changeAmount(O) G. acct. changeAmount(-acct amount) H. acct change Amount(-acct getAmounto) Correct Answer: DGH Section: (none) Explanation Explanation/Reference: QUESTION 14 Given the code fragment string shirts[][]= new string[2][2] shirts[o[o] shirts[o][1 shirts[1][o] small shirts[il[ll =medium Which code fragment prints red: blue: small: medium? C A for (int inde i: inde : index十+) Ior 1nt 1dx dx 2 ldx++ System. out. print (shirts[indexlidx CB)f。r( ant index=0 de 已;十+ index for int ida =0: ldx index; ++idm dystem out. print (shirts[index[idx]+:) C)for (string lors for (string s: sizes) Systerm. out. printin(s+ cD)for (int index =0; index 2:)( n七id idx <2:35 System, out. print (shirts[index][idx]+:)F ldx++i dext+ A. Option A B. Option B C. Option c 【实例截图】
【核心代码】
标签:
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论