所需积分/C币:20 2012-05-28 21:16:15 5.68MB PDF
收藏 收藏

void waitForsignal()i Oo-ect obj=new○ oject() synchronized (Thread curren- Thread())i bj. wait()i tify( Which statement is true? A. This code can throw an InterruptedException B. This code can throw an IegalMonitor State Exception C. This code can throw a T imeoutException after ten minutes. D. Reversing the order of obj. wait( and obj. notify( might cause this method to complete normally. E. A call to notify( or notify Allo from another thread might cause this method to complete normally F. This code does NoT compile unless obj. waito"is replaced with"(Thread) obj). wait() Answer: B Explanation /Reference Threads2 java: 15: unreported exception java. lang. InterruptedException; must be caught or declared to be thrown ○bj.wait(); 1 eror La respuesta que aparece antes de la correccion era"This code can throw an llegaIMonitor State Exception pero las excepciones IegaIMonitor State Exception se usan QUESTION 4 Click the Exhibit button What is the output if the main( method is run? 1. public class Starter extends Thread f private int x=2 23456789 public static void main(String[] args)throws Exception new Starter(). makeitso() public starter()i start( 0. public void makeItSo() throws Exception i O1n() 12 13 System, out. printin(x)i 14 16/ public void run ()i x *= 2; 15 BCD 8 9 E. Compilation fails F. An exception is thrown at runtime G. It is impossible to determine for certain Answer: D Explanation/Reference: QUESTION 5 Given class pingPong 123456 synchronized void hit(long n)( f。卫 System. out. print (n +1+ 1. public class Tester implements Runnable static PingPcng2 pp2= new PingPong2()i 234567 public static void main(String[] args)t new Thread (new Tester()). start( new Thread(new Tester()).start()i public void run() pp2hit (Thread currentThread(). getid())i Which statement is true? A. The output could be 5-1 6-16-2 5-2 B. The output could be 6-1 6-2 5-1 5-2 C. The output could be 6-1 5-2 6-2 5-1 D. The output could be 6-1 6-2 5-17-1 Answer: B Explanation/Reference: La respuesta se obtiene es por la secuencia del segundo numero n-1n-2n-1n-2 QUESTION 6 Given public class Threads t public static void main (String[] args) i 23456789 new Threads(). go() public void go() i Runnable r= new Runnable()i public void run() System. out. print("foo")i 10 Thread t= new Thread(r)i t start()i 2345 start()i What is the result? A. Compilation fails B. An exception is thrown at runtime C. The code executes normally and prints"foo D. The code executes normally, but nothing is printed Answer: B Explanation /Reference fooEXception in thread "main" java. lang. Illegal Thread State EXception at java.lang. Thread. start ( Unknown Source) at p6. Threads 4. go(Threads. ava: 15) at p6. Threads 4 main(Threads4java: 5) QUESTION 7 Given public abstract class shape private int private inti public abstract void draw( 456789 public void setAnchor(int x, int y) this, x=x: this y = yi Which two classes use the Shape class correctly?(Choose two A. public class Circle implements shape private int radius B. Public abstract class circle extends Shape private int radius public class Circle extends shape private int radius i public void draw()i D. public abstract class Circle implements Shape t private int radius public void draw() E. public class Circle extends Shape t private int radius public void draw() [/* code here */1 F. public abstract class circle implements shape i private int radius public void draw() [/* code here */ Answer: BE Explanation/Reference QUeStIon 8 Given 1. public class Barn i public static void main(String[] args)i new Barn().go(hi 1)i new Barn().go("hi","world"2)i 6 public void go(string., y, int x) 789 System.out. print(yy.⊥ erath--」+"") What is the result? A. hi hi B. hi world C. world world D. Compilation fails E. An exception is thrown at runtime Answer: D Explanation/Reference The method go( Stringl int)in the type Barn is not applicable for the arguments(String, int) The variable argument type String of the method go must be the last parameter QUESTION 9 Given 1. class Navi 2 public enum Direction t NCRTH, SOUTH, FAST, WE ST H 1. public class Sprite( 23 insert code here Which code, inserted at line 14, allows the Sprite class to com pile? A. Direction d= NOrTH B. Nav Direction d= NORTH C. Direction d= Direction. NORTH D. Nav. Direction d= Nav. Direction. NORTH Answer: D Explanation /Reference: QUESTION 10 Click the Exhibit button Which statement is true about the classes and interfaces in the exhibit? public interface A public void dosomething(St=ing thing )i public class Almpl implements A 2. public void doSomething(string msg)t I public class B 2 public A doit()( //more ccde here public String execute()i //more ccde here 1. public class C extends B i public IMpl doit( 23456789 /more ccde here public object execute() //more ccde here A. Compilation will succeed for all classes and interfaces B. Compilation of class c will fail because of an error in line 2 C. Compilation of class c will fail because of an error in line 6 D. Compilation of class almpl will fail because of an error in line 2 Answer: C Explanation/Reference The return type is incompatible with Bexecute( QUESTION 11 Click the Exhibit button What is the result? 11. public class peson t 12 String name No name i 13 public Person(string nm)[ name - nm 14.} 16. public class Employee extends person I 17 String empID =0000i 18 public Employee(String id)i empT =idi j 90 21. public class EmployeeTest. t 22 public static void main(String[ args) 23 上mp1 ovee e=new上 mplcyee("4321") 24 System, ouc printin(e empID)i 25 A.4321 B.0000 C. An exception is thrown at runtime D. Compilation fails because of an error in line 18 Answer : D Explanation/Reference: Implicit super constructor Person( is undefined. Must explicitly invoke another constructor QUESTION 12 Given public class Rainbow f public enum NyColor 234567 RED(OxI=o000), green (oxcoffoo), Blue(0x000oft)i private final int rgbi MyColor(int rgb)i this rgb public int getRGB()[ return rgbi j 8. public static void main(String[ args)t 9. l/insert code here 10 Which code fragment, inserted at line 19, allows the Rainbow class to compile? A. My Color skyColor= blUE i B. My Color treeCclor MyColor grEeN i C. if(RED. getRGB()< BLUE. getRGE()) D. Compilation fails due to other error(s)in the code E. My Color purple new My Color(Oxffooff F. My Color purple= MyCo MyCoLor. BLUE MyColorRED; Answer: B Explanation/Reference QUESTION 13 Given: 1. public class Mud 2345 //insert code here System. out. printin(whi")i And the following five fragments public static void main(String. a)[ public static void main(string.* a) f public static void main(string,. a)i public static void main(String[] public static void main(string How many of the code fragments, inserted independently at line 2, compile? 2 E.4 F.5 Answer: D Explanation/Reference: public static void main(String.a) t public static void main(string,. a) public static void main(String QUESTION 14 Given 1. class Atom Atom() System. out. print("atom )i 4. class Rock extends Atom Rock(string type)i System.out. print (type)i 6. 7. public class Mountain extends Rock t Mountain( i super(granite )i 0. new Rock(granite 12. public static void main(string[] a)[ new Mountain()i 1 13 What is the result? A. Compilation fails B. atom granite C. granite granite D. atom granite granite E. An exception is thrown at runtime F. atom granite atom granite Answer: F Explanation/Reference: QUESTION 15 nterface Testa[ String toString()i) public class Test public static void main(string[] args) i System. out. println(new TestA() t )) )). public Sring tostring(i return " test";: What is the result? B C. An exception is thrown at runtime D. Compilation fails because of an error in line 1 E. Compilation fails because of an error in line 4 F. Compilation fails because of an error in line 5 Answer:A Explanation/ Reference: QUESTION 16 Given public static void parse(String str)( ry float f=Float parseFloat 4. 3 catch (NumberFormatExceotion nfe)( 5. f=0; }£ina11 System. out. printin(f)i 8. 10. public static void main (String[] args)t parse(invalid) 12 What is the result? A.0.0 B. Compilation fails C. A Parse Exception is thrown by the parse method at runtime D. A Number FormatException is thrown by the parse method at runtime Answer: B Explanation/Reference: f cannot be resolved en la linea 5y 7 QUESTION 17 Given 1. public class Blip i 2345 protected int blipvert(int x)t return Ci 1 Vert extends Blip insert code here 6.} Which five methods, inserted independently at line 5, will compile?(Choose five A. public int blipvert(int x)i return 0; F B. private int blipvert(int x) return 0; 1 C. private int blipvert(long x) return 0; 1 D. protected long blipvert(int x) return C; 1 E. protected int blipvert(long x)i return 0 F. protected long blipvert(long x)i return 0 i G. protected long blipvert(int x, int y)[ return oi H Answer: ACEFG Explanation/Reference: private int blipvert(int x)[ return 0;: Cannot reduce the visibility of the inherited method from Blip protected long blipvert(int x)i return 0i H The return type is incompatible with Blip blipvert(int) QUESTION 18 Given 1. class super private int ai protected Super(int a)[ this. a ai J 11. class Sub extends Super t 12. public Sub(int a) super(a) public Sub()this,a 5;}

试读 127P ORACLE认证考试ocjp题库(覆盖率99%)本人刚考完
立即下载 低至0.43元/次 身份认证VIP会员低至7折
s316297025 题目很全,准备好好学习一下。
木木钧 资源虽好, 但也有很多跟这个内容类似的资源, 后来找到了也就1个积分而已
qianyinzhong 正在准备OCJP考试,本资源是Java6,现在靠Java7了,不过还是有帮助
wanglele0 题目很全,准备好好学习一下。
guanhuichen 对我的项目有用
云醉红尘 题库不错,对考试有用
EzrealJi 题目很全,不过理解很重要,并不是所有的都是原题
Dazie 整理得还不错,本人已经通过了
shql2000 为什么看起来像是考试机构的复习题呢
haipobo 还没考,题目很专业
关注 私信
ORACLE认证考试ocjp题库(覆盖率99%)本人刚考完 20积分/C币 立即下载

试读结束, 可继续阅读

20积分/C币 立即下载 >