Tin Học >> Lập trình >> Java
|| C#
C++
Visual Basic
Visual Foxpro
C
Java
Pascal
Thiết Kế Web
ASP.NET
XML
CSS
PHP
Có 55 bài trong 6 trang (10 bài/trang) và bạn đang ở trang 1.
You need to store elements in a collection that guarantees that no duplicates are stored. Which one of the following interfaces provide that capability? A. Java.util.Map B. Java.util.List C. Java.util.Collection D. None of the above...... Which collection class allows you to access its elements by associating a key with an element's value, and provides synchronization? A. java.util.SortedMap B. java.util.TreeMap C. java.util.TreeSet D. java.util.Hashtable......... What will be the output of the program? public class Test { public int aMethod() { static int i = 0; i++; return i; } public static void main(String args[]) { Test test = new Test(); test.aMethod(); int j = test.aMethod(); System.out.println(j); } } A. 0 B. 1 C. 2 D. Compilation fails........ What will be the output of the program? class PassA { public static void main(String [] args) { PassA p = new PassA(); p.start(); } void start() ......... Which cannot directly cause a thread to stop executing? A. Calling the SetPriority() method on a Thread object. B. Calling the wait() method on an object. C. Calling notify() method on an object. D. Calling read() method on an InputStream object........ Which method registers a thread in a thread scheduler? A. run(); B. construct(); C. start(); D. register();....... What will be the output of the program? class Super { public int i = 0; public Super(String text) /* Line 4 */ { i = 1; } } class Sub extends Super { public Sub(String text) { i = 2; } public static void main(String args[]) { Sub sub = new Sub("Hello"); System.out.println(sub.i); } } A. 0 B. 1 C. 2 D. Compilation fails........ What will be the output of the program? public abstract class AbstractTest { public int getNum() { return 45; } public abstract class Bar { public int getNum() { return 38; } } public static void main (String [] args) { AbstractTest t = new AbstractTest() { public int getNum() { return 22; } }; AbstractTest.Bar f = t.new Bar() { public int getNum() { return 57; } }; System.out.println(f.getNum() + " " + t.getNum()); } } A. 57 22 B. 45 38 C. 45 57 D. An exception occurs at runtime........ Which two of the following are legal declarations for nonnested classes and interfaces? final abstract class Test {} public static interface Test {} final public class Test {} protected abstract class Test {} protected interface Test {} abstract public class Test {} A. 1 and 4 B. 2 and 5 C. 3 and 6 D. 4 and 6........ public class While { public void loop() { int x= 0; while ( 1 ) /* Line 6 */ { System.out.print("x plus one is " + (x + 1)); /* Line 8 */ } } } Which statement is true? A. There is a syntax error on line 1........ Which of the following statements about the hashcode() method are incorrect? The value returned by hashcode() is used in some collection classes to help locate objects. The hashcode() method is required to return a positive int value. The hashcode() method in the String class is the one inherited from Object. Two new empty String objects will produce identical hashcodes. A. 1 and 2 B. 2 and 3 C. 3 and 4 D. 1 and 4.... What will be the output of the program? public class TestObj { public static void main (String [] args) { Object o = new Object() /* Line 5 */ { public boolean equals(Object obj) { return true; } } /* Line 11 */........ Which cause a compiler error? A. int[ ] scores = {3, 5, 7}; B. int [ ][ ] scores = {2,7,6}, {9,3,45}; C. String cats[ ] = {"Fluffy", "Spot", "Zeus"}; D. boolean results[ ] = new boolean [] {true, false, true}; E. Integer results[ ] = {new Integer(3), new Integer(5), new Integer(8)};...... Which three are valid method signatures in an interface? private int getArea(); public float getVol(float x); public void main(String [] args); public static void main(String [] args);...... What will be the output of the program? public class SyncTest { public static void main (String [] args) { Thread t = new Thread() { Foo f = new Foo(); public void run() { f.increase(20); } }; t.start(); } } class Foo { private int data = 23; public void increase(int amt) { int x = data; data = x + amt; } } and assuming that data must be protected from corruption, what—if anything—can you add to the preceding code to ensure the integrity of data? A. Synchronize the run method. B. Wrap a synchronize(this) around the call to f.increase(). C. The existing code will cause a runtime exception. D. Synchronize the increase() method......... What is the most restrictive access modifier that will allow members of one class to have access to members of another class in the same package? A. public B. abstract C. protected D. synchronized E. default access....... You want a class to have access to members of another class in the same package. Which is the most restrictive access that accomplishes this objective? A. public B. private C. protected D. default access........ |