Which statements concerning the methods notify() and notifyAll() are true?
AInstances of class Thread have a method called notify().
BA call to the method notify() will wake the thread that currently owns the monitor of the object.
CThe method notify() is synchronized.
DThe method notifyAll() is defined in class Thread.
EWhen there is more than one thread waiting to obtain the monitor of an object, there is no way to be sure which thread will be notified by the notify() method.
相关问题推荐
-
34. HashMap props = new HashMap(); 35. props.put(”key45”, “some value”); 36. props.put(”key12”, “some other value”); 37. props.put(”key39”, “yet another value”); 38. Set s = props.keySet(); 39. // insert code here What, inserted at line 39, will sort the keys in the props HashMap?()
A、 Arrays.sort(s);
B、 s = new TreeSet(s);
C、 Collections.sort(s);
D、 s = new SortedSet(s);
-
Given a vaid DateFormat object named df, and What updates d’s value with the date represented by ds?()
A、 18.d=df.parse(ds);
B、 18.d=df.getDate(ds);
C、 18.try{19.d=df.parse(ds);20. }catch(ParseException e){ }
D、 18.try{19.d=df.getDate(ds);20. }catch(ParseException e){ }
-
A Button is positioned in a Frame. Only height of the Button is affected by the Frame while the width is not. Which layout manager should be used?()
A、 FlowLayout
B、 CardLayout
C、 North and South of BorderLayout
D、 East and West of BorderLayout
E、 GridLayout
-
interface Beta {} class Alpha implements Beta { String testIt() { return “Tested”; } } public class Main1 { static Beta getIt() { return new Alpha(); } public static void main( String[] args ) { Beta b = getIt(); System.out.println( b.testIt() ); } } What is the result?()
A、 Tested
B、 Compilation fails.
C、 The code runs with no output.
D、 An exception is thrown at runtime.
-
ClassOne.java 1. package com.abc.pkg1; 2. public class ClassOne { 3. private char var = ‘a’; 4. char getVar() {return var;} 5. } ClassTest.java 1. package com.abc.pkg2; 2. import com.abc.pkg1.ClassOne; 3. public class ClassTest extends ClassOne { 4. public static void main(String[]args) { 5. char a = new ClassOne().getVar(); 6. char b = new ClassTest().getVar(); 7. } 8. } What is the result?()
A、 Compilation will fail.
B、 Compilation succeeds and no exceptions are thrown.
C、 Compilation succeeds but an exception is thrown at line 5 in ClassTest.java.
D、 Compilation succeeds but an exception is thrown at line 6 in ClassTest.java.